From ee6dac4a9d3a4293762184da3a6efb1f0866b1ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 21:14:44 +0000 Subject: [PATCH 1/7] Initial plan From a8bfcee27f5fcea28cebf486a7bae53d3f464d16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 21:23:47 +0000 Subject: [PATCH 2/7] Add Enter key support for single-choice information dialogs Co-authored-by: haslinghuis <8344830+haslinghuis@users.noreply.github.com> --- src/js/gui.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/js/gui.js b/src/js/gui.js index b48f97089d..fe8ccecf7d 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -381,9 +381,21 @@ class GuiControl { buttonConfirm.off("click"); - buttonConfirm.on("click", () => { + const confirmAction = () => { dialog[0].close(); + dialog.off("keydown"); resolve(); + }; + + buttonConfirm.on("click", confirmAction); + + // Add Enter key support for single-choice dialog + dialog.off("keydown"); + dialog.on("keydown", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + confirmAction(); + } }); dialog[0].showModal(); From 4d79561127fafd7e0972ea5e5685a313de02e883 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 21:27:47 +0000 Subject: [PATCH 3/7] Add clarifying comment for keydown handler cleanup Co-authored-by: haslinghuis <8344830+haslinghuis@users.noreply.github.com> --- src/js/gui.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/gui.js b/src/js/gui.js index fe8ccecf7d..29a494c089 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -390,6 +390,7 @@ class GuiControl { buttonConfirm.on("click", confirmAction); // Add Enter key support for single-choice dialog + // Remove any previous keydown handlers before adding new one dialog.off("keydown"); dialog.on("keydown", (e) => { if (e.key === "Enter") { From 50abdb4c17779a6566a0582c11cefdbbda44b932 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 20:40:08 +0000 Subject: [PATCH 4/7] Fix Enter key detection to use e.which and document listener Co-authored-by: haslinghuis <8344830+haslinghuis@users.noreply.github.com> --- src/js/gui.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/js/gui.js b/src/js/gui.js index 29a494c089..3f86c067d1 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -383,17 +383,16 @@ class GuiControl { const confirmAction = () => { dialog[0].close(); - dialog.off("keydown"); + $(document).off("keydown.informationDialog"); resolve(); }; buttonConfirm.on("click", confirmAction); // Add Enter key support for single-choice dialog - // Remove any previous keydown handlers before adding new one - dialog.off("keydown"); - dialog.on("keydown", (e) => { - if (e.key === "Enter") { + $(document).off("keydown.informationDialog"); + $(document).on("keydown.informationDialog", (e) => { + if (e.which === 13) { e.preventDefault(); confirmAction(); } From c8f44bd1edc7048348edd59c36cff0a2fee2b5ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 20:41:39 +0000 Subject: [PATCH 5/7] Add safety check to prevent Enter key on input/textarea elements Co-authored-by: haslinghuis <8344830+haslinghuis@users.noreply.github.com> --- src/js/gui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/gui.js b/src/js/gui.js index 3f86c067d1..63ab6fed46 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -392,7 +392,8 @@ class GuiControl { // Add Enter key support for single-choice dialog $(document).off("keydown.informationDialog"); $(document).on("keydown.informationDialog", (e) => { - if (e.which === 13) { + // Only trigger if Enter key is pressed and target is not an input/textarea + if (e.which === 13 && !$(e.target).is("input, textarea")) { e.preventDefault(); confirmAction(); } From aa6f589fe50163b4d6f3419a4bc04e5839cb569b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 20:52:39 +0000 Subject: [PATCH 6/7] Add dialog.open check to prevent Enter key trigger when dialog is closed Co-authored-by: haslinghuis <8344830+haslinghuis@users.noreply.github.com> --- src/js/gui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/gui.js b/src/js/gui.js index 63ab6fed46..dc00823073 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -392,8 +392,8 @@ class GuiControl { // Add Enter key support for single-choice dialog $(document).off("keydown.informationDialog"); $(document).on("keydown.informationDialog", (e) => { - // Only trigger if Enter key is pressed and target is not an input/textarea - if (e.which === 13 && !$(e.target).is("input, textarea")) { + // Only trigger if Enter is pressed, dialog is open, and target is not an input/textarea + if (e.which === 13 && dialog[0].open && !$(e.target).is("input, textarea")) { e.preventDefault(); confirmAction(); } From 9cc4d0d6ed0df3973d720c0f4f31060b0bc814b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 20:57:13 +0000 Subject: [PATCH 7/7] Refactor to use dialog close event for cleanup and promise resolution Co-authored-by: haslinghuis <8344830+haslinghuis@users.noreply.github.com> --- src/js/gui.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/js/gui.js b/src/js/gui.js index dc00823073..b71a561905 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -383,21 +383,26 @@ class GuiControl { const confirmAction = () => { dialog[0].close(); - $(document).off("keydown.informationDialog"); - resolve(); }; buttonConfirm.on("click", confirmAction); // Add Enter key support for single-choice dialog - $(document).off("keydown.informationDialog"); - $(document).on("keydown.informationDialog", (e) => { + const handleKeydown = (e) => { // Only trigger if Enter is pressed, dialog is open, and target is not an input/textarea if (e.which === 13 && dialog[0].open && !$(e.target).is("input, textarea")) { e.preventDefault(); confirmAction(); } - }); + }; + + $(document).on("keydown.informationDialog", handleKeydown); + + // Clean up event listener when dialog closes + dialog[0].addEventListener("close", () => { + $(document).off("keydown.informationDialog", handleKeydown); + resolve(); + }, { once: true }); dialog[0].showModal(); });