From 97b03ed7ed508baf893a39bb1069bf7362b4eb43 Mon Sep 17 00:00:00 2001 From: Dane Middleton <29767622+melonunderground@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:11:36 -0600 Subject: [PATCH 1/2] fix(uber_search): prevent esc key hiding select options - move Esc pane-hide from global pane.js to uber_search.js - prevent panes being hidden with no selectable/visible options --- javascript/uber_search.js | 8 ++++++++ javascript/uber_search/pane.js | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/javascript/uber_search.js b/javascript/uber_search.js index 07b0fa3..d5ca047 100644 --- a/javascript/uber_search.js +++ b/javascript/uber_search.js @@ -82,6 +82,14 @@ } }) + // Hide the pane when the user presses escape + $(view).on('keyup', function(event){ + if (!options.alwaysOpen && pane.isOpen() && event.which == 27) { + pane.hide() + return false + } + }) + $(view).on('setHighlight', function(event, result, index) { if (index < 0 && options.search) { setOutputContainerAria("aria-activedescendant", "") diff --git a/javascript/uber_search/pane.js b/javascript/uber_search/pane.js index 286e71f..cb09970 100644 --- a/javascript/uber_search/pane.js +++ b/javascript/uber_search/pane.js @@ -34,13 +34,6 @@ context.hide() }) - // Close the pane when the user presses escape - $(document).on('keyup', function(event){ - if (event.which == 27 && isOpen){ - context.hide() - return false - } - }) // HELPER FUNCTIONS From 6e78f878e18da4a63d5385a69c2f52d83c88d5c1 Mon Sep 17 00:00:00 2001 From: Dane Middleton <29767622+melonunderground@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:36:49 -0600 Subject: [PATCH 2/2] fix(pane): pass alwaysOpen to pane for Esc handling - esc key close handled in pane - pass alwaysOpen from UberSearch to pane - skip esc close when alwaysOpen true - update is safe as options is only read, not mutated --- javascript/uber_search.js | 10 +--------- javascript/uber_search/pane.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/javascript/uber_search.js b/javascript/uber_search.js index d5ca047..cb96680 100644 --- a/javascript/uber_search.js +++ b/javascript/uber_search.js @@ -43,7 +43,7 @@ var outputContainer = options.outputContainer || new UberSearch.OutputContainer({selectCaret: options.selectCaret, ariaLabel: options.ariaLabel}) var resultsContainer = $('
') var messages = $('') - var pane = new UberSearch.Pane() + var pane = new UberSearch.Pane({alwaysOpen: options.alwaysOpen}) var searchField = new UberSearch.SearchField({ placeholder: options.searchPlaceholder, @@ -82,14 +82,6 @@ } }) - // Hide the pane when the user presses escape - $(view).on('keyup', function(event){ - if (!options.alwaysOpen && pane.isOpen() && event.which == 27) { - pane.hide() - return false - } - }) - $(view).on('setHighlight', function(event, result, index) { if (index < 0 && options.search) { setOutputContainerAria("aria-activedescendant", "") diff --git a/javascript/uber_search/pane.js b/javascript/uber_search/pane.js index cb09970..bfc04fd 100644 --- a/javascript/uber_search/pane.js +++ b/javascript/uber_search/pane.js @@ -1,10 +1,14 @@ (function($) { - UberSearch.Pane = function() { + UberSearch.Pane = function(options) { var eventsTriggered = { shown: 'shown', hidden: 'hidden' } + options = $.extend({ + alwaysOpen: false + }, options) + var context = this var model = {} var isOpen = false @@ -34,6 +38,15 @@ context.hide() }) + // Close the pane when the user presses escape + if (!options.alwaysOpen) { + $(document).on('keyup', function(event){ + if (event.which == 27 && isOpen){ + context.hide() + return false + } + }) + } // HELPER FUNCTIONS