Commit 676dbbef authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

[footer] Enable arrow keys for closed select

CL:2201336 swaps out the native <select> control for a <div> that
implements the same functionality so that it can be styled for files-ng.

Add keyboard navigation when the control is collapsed to allow changing
the filtered options without expanding the control.

Fires a change event if the selection is changed with the control closed
so that the filtered name gets updated correctly.

Bug: 1097454, 1002410
Change-Id: Ic2e8c06ef309e4cd1090dc9a48622bf92c7e3666
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2282829
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786167}
parent 16610e4d
...@@ -214,24 +214,29 @@ class DialogFooter { ...@@ -214,24 +214,29 @@ class DialogFooter {
break; break;
case 'ArrowDown': case 'ArrowDown':
case 'ArrowUp': case 'ArrowUp':
if (options.getAttribute('expanded') === 'expanded') { const selectedItem = options.querySelector('.selected');
const selectedItem = options.querySelector('.selected'); let selectionChanged = false;
if (selectedItem) { if (selectedItem) {
if (evt.key === 'ArrowDown') { if (evt.key === 'ArrowDown') {
if (selectedItem.nextSibling) { if (selectedItem.nextSibling) {
this.setOptionSelected( this.setOptionSelected(
/** @type {HTMLOptionElement} */ ( /** @type {HTMLOptionElement} */ (selectedItem.nextSibling));
selectedItem.nextSibling)); selectionChanged = true;
} }
} else { // ArrowUp. } else { // ArrowUp.
if (selectedItem.previousSibling) { if (selectedItem.previousSibling) {
this.setOptionSelected( this.setOptionSelected(
/** @type {HTMLOptionElement} */ ( /** @type {HTMLOptionElement} */ (
selectedItem.previousSibling)); selectedItem.previousSibling));
} selectionChanged = true;
} }
} }
} }
if (selectionChanged &&
options.getAttribute('expanded') !== 'expanded') {
const changeEvent = new Event('change');
this.fileTypeSelector.dispatchEvent(changeEvent);
}
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment