Make input popups respect "Enter to Send" setting

1f6a91ab5d9417a1386f2f10d3b2a7a75f18df3b

Wolfsblvt <wolfsblvt@gmx.de>

1 files changed, +10 -1Showing whitespace changes
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);