From 524c156147e958715be66ff8c5b44d8386430590 Mon Sep 17 00:00:00 2001 From: Max Kadel Date: Tue, 28 Jan 2025 16:20:39 -0500 Subject: [PATCH] Does not actually allow you to select You can use the arrow key to go to the first item in the list, but then every time you press it takes you back to the first item in the list --- .../orangelight/multiselect_combobox.es6 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/javascript/orangelight/multiselect_combobox.es6 b/app/javascript/orangelight/multiselect_combobox.es6 index 24031e36e..4fbd9f410 100644 --- a/app/javascript/orangelight/multiselect_combobox.es6 +++ b/app/javascript/orangelight/multiselect_combobox.es6 @@ -53,7 +53,21 @@ export default class MultiselectCombobox { this.listElement.querySelectorAll('li').forEach((item) => { this.#addEventListener(item); }); - this.inputElement.addEventListener('input', (event) => { + this.inputElement.addEventListener('keyup', (event) => { + const isUpOrDownEvent = ['ArrowUp', 'ArrowDown'].includes(event.key); + const getToggleButton = event.target; + const instance = bootstrap.Dropdown.getOrCreateInstance(getToggleButton); + if (isUpOrDownEvent) { + event.stopPropagation(); + instance.show(); + + instance._selectMenuItem(event); + + return; + } + console.log(`I'm in the event listener for event: ${event}`); + }); + this.inputElement.addEventListener('keyup', (event) => { this.updateOptionVisibility(); this.#openDropdownIfClosed(); });