Merge pull request #2453 from SillyTavern/input-popup-respect-enter-to-send
Make input popups respect "Enter to Send" setting
This commit is contained in:
commit
ce92385454
|
@ -1,3 +1,4 @@
|
|||
import { shouldSendOnEnter } from './RossAscends-mods.js';
|
||||
import { power_user } from './power-user.js';
|
||||
import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js';
|
||||
|
||||
|
@ -344,11 +345,19 @@ export class Popup {
|
|||
if (this.dlg != document.activeElement?.closest('.popup'))
|
||||
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');
|
||||
if (!resultControl)
|
||||
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.stopPropagation();
|
||||
const result = Number(document.activeElement.getAttribute('data-result') ?? this.defaultResult);
|
||||
|
|
Loading…
Reference in New Issue