Merge pull request #2453 from SillyTavern/input-popup-respect-enter-to-send Make input popups respect "Enter to Send" setting

ce92385454fd179ddb998663bbb19aaef85b13b7

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +10 -1Ignore whitespace
public/scripts/popup.js+10 -1
@@ -1,3 +1,4 @@
1+import { shouldSendOnEnter } from './RossAscends-mods.js';
12import { power_user } from './power-user.js';
23import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js';
34
@@ -344,11 +345,19 @@ export class Popup {
344345 if (this.dlg != document.activeElement?.closest('.popup'))
345346 return;
346347
347348 // Check if the current focus is a result control. Only should we apply the compeletecomplete action
348349 const resultControl = document.activeElement?.closest('.result-control');
349350 if (!resultControl)
350351 return;
351352
353+ // Check if we are inside an input type text or a textarea field and send on enter is disabled
354+ const textarea = document.activeElement?.closest('textarea');
355+ if (textarea instanceof HTMLTextAreaElement && !shouldSendOnEnter())
356+ return;
357+ const input = document.activeElement?.closest('input[type="text"]');
358+ if (input instanceof HTMLInputElement && !shouldSendOnEnter())
359+ return;
360+
352361 evt.preventDefault();
353362 evt.stopPropagation();
354363 const result = Number(document.activeElement.getAttribute('data-result') ?? this.defaultResult);