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 @@
1import { shouldSendOnEnter } from './RossAscends-mods.js';
1import { power_user } from './power-user.js';2import { power_user } from './power-user.js';
2import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js';3import { removeFromArray, runAfterAnimation, uuidv4 } from './utils.js';
34
@@ -344,11 +345,19 @@ export class Popup {
344 if (this.dlg != document.activeElement?.closest('.popup'))345 if (this.dlg != document.activeElement?.closest('.popup'))
345 return;346 return;
346347
347 // Check if the current focus is a result control. Only should we apply the compelete action348 // Check if the current focus is a result control. Only should we apply the complete action
348 const resultControl = document.activeElement?.closest('.result-control');349 const resultControl = document.activeElement?.closest('.result-control');
349 if (!resultControl)350 if (!resultControl)
350 return;351 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
352 evt.preventDefault();361 evt.preventDefault();
353 evt.stopPropagation();362 evt.stopPropagation();
354 const result = Number(document.activeElement.getAttribute('data-result') ?? this.defaultResult);363 const result = Number(document.activeElement.getAttribute('data-result') ?? this.defaultResult);