mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Make input popups respect "Enter to Send" setting
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import { shouldSendOnEnter } from './RossAscends-mods.js';
|
||||||
import { power_user } from './power-user.js';
|
import { power_user } from './power-user.js';
|
||||||
import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js';
|
import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js';
|
||||||
|
|
||||||
@ -344,11 +345,19 @@ export class Popup {
|
|||||||
if (this.dlg != document.activeElement?.closest('.popup'))
|
if (this.dlg != document.activeElement?.closest('.popup'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if the current focus is a result control. Only should we apply the compelete action
|
// Check if the current focus is a result control. Only should we apply the complete action
|
||||||
const resultControl = document.activeElement?.closest('.result-control');
|
const resultControl = document.activeElement?.closest('.result-control');
|
||||||
if (!resultControl)
|
if (!resultControl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Check if we are inside an input type text or a textarea field and send on enter is disabled
|
||||||
|
const textarea = document.activeElement?.closest('textarea');
|
||||||
|
if (textarea instanceof HTMLTextAreaElement && !shouldSendOnEnter())
|
||||||
|
return;
|
||||||
|
const input = document.activeElement?.closest('input[type="text"]');
|
||||||
|
if (input instanceof HTMLInputElement && !shouldSendOnEnter())
|
||||||
|
return;
|
||||||
|
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
const result = Number(document.activeElement.getAttribute('data-result') ?? this.defaultResult);
|
const result = Number(document.activeElement.getAttribute('data-result') ?? this.defaultResult);
|
||||||
|
Reference in New Issue
Block a user