Skip to content

Commit

Permalink
Test for keyboard nav in multiselect combobox
Browse files Browse the repository at this point in the history
Co-authored-by: Jane Sandberg <[email protected]>
Co-authored-by: Carolyn Cole <[email protected]>
Co-authored-by: Christina Chortaria <[email protected]>
  • Loading branch information
4 people committed Jan 29, 2025
1 parent 524c156 commit 60cbd28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/javascript/orangelight/multiselect_combobox.es6
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ export default class MultiselectCombobox {
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();
Expand All @@ -79,6 +77,8 @@ export default class MultiselectCombobox {
(event) => {
if (event.code == 'Enter') {
this.toggleItem(item);
} else if (event.code == 'ArrowUp' || event.code == 'ArrowDown') {
return;
} else {
// Send all other events to the input, so that
// anything the user types ends up there
Expand Down
5 changes: 5 additions & 0 deletions spec/system/numismatics_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
end
page.send_keys(:down)
expect(page).to have_content('shekel')
active_element = page.evaluate_script("document.activeElement")
expect(active_element.text).to eq("1/2 Penny (1)")
page.send_keys(:down)
active_element = page.evaluate_script("document.activeElement")
expect(active_element.text).to eq("follis (1)")
end
end

0 comments on commit 60cbd28

Please sign in to comment.