From 007649296b8e52c7e67a1f822ebce6189799a1ba Mon Sep 17 00:00:00 2001 From: jelveh Date: Wed, 29 Jul 2026 19:40:16 -0700 Subject: [PATCH] Keyboard: stop swallowing Enter when nothing claims it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The global Enter handler preventDefault'ed unconditionally, then returned without acting unless a launch-menu item, context-menu item, or selected item existed. That suppressed the browser's native Enter activation on whatever was focused — a focused link or button (e.g. a dashboard sidebar item, a dialog button) did nothing on Enter. Move preventDefault/stopPropagation into the branches that actually handle the key; otherwise fall through so native activation runs. The handled paths are unchanged: Enter still opens the selected item, launch-menu entry, and context-menu entry. --- src/gui/src/keyboard.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/gui/src/keyboard.js b/src/gui/src/keyboard.js index e41bbbce0..ea71e5adc 100644 --- a/src/gui/src/keyboard.js +++ b/src/gui/src/keyboard.js @@ -789,15 +789,19 @@ $(document).bind('keyup keydown', async function (e) { if ( e.which === 13 && !$(focused_el).is('input') && !$(focused_el).is('textarea') && (Date.now() - window.last_enter_pressed_to_rename_ts) > 200 // prevent firing twice, because this will be fired on both keyup and keydown && e.type === 'keydown' ) { - let $selected_items; - - e.preventDefault(); - e.stopPropagation(); + // preventDefault only happens in the branch that actually handles + // the key: an unconditional preventDefault here would suppress the + // browser's native Enter activation of whatever is focused — a + // focused link or button (e.g. a dashboard sidebar item) must + // still receive its synthesized click when nothing below claims + // the key. // --------------------------------------------- // if this is a selected Launch menu item, open it // --------------------------------------------- if ( $('.launch-app-selected').length > 0 ) { + e.preventDefault(); + e.stopPropagation(); // close launch menu $('.launch-popover').fadeOut(200, function () { launch_app({ @@ -814,6 +818,8 @@ $(document).bind('keyup keydown', async function (e) { // if this is a selected context menu item, open it // --------------------------------------------- else if ( $('.context-menu-active .context-menu-item-active').length > 0 && (e.which === 13) ) { + e.preventDefault(); + e.stopPropagation(); let selected_item = $('.context-menu-active .context-menu-item-active').get(0); $(selected_item).removeClass('context-menu-item-active'); $(selected_item).addClass('context-menu-item-active-blurred'); @@ -830,19 +836,21 @@ $(document).bind('keyup keydown', async function (e) { // if this is a selected item, open it // --------------------------------------------- else if ( window.active_item_container ) { - $selected_items = $(window.active_item_container).find('.item-selected'); + const $selected_items = $(window.active_item_container).find('.item-selected'); if ( $selected_items.length > 0 ) { + e.preventDefault(); + e.stopPropagation(); $selected_items.each(function () { open_item({ item: this, new_window: e.metaKey || e.ctrlKey, }); }); + return false; } - return false; } - - return false; + // Nothing claimed the key — fall through so the browser's default + // Enter behavior still runs on the focused element. } //---------------------------------------------- // Paste