Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1874015 - Can no longer open-select-close bugzilla dropdowns in a single drag gesture #2169

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions js/components/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,15 @@ class BzSelectElement extends HTMLElement {
this.#slot = this.shadowRoot.querySelector('slot');
this.#noMatchMessage = this.shadowRoot.querySelector('.no-match');

this.#combobox.addEventListener('click', (event) => this.#onComboboxClick(event));
this.#combobox.addEventListener('mousedown', (event) => this.#onComboboxMouseDown(event));
this.#combobox.addEventListener('keydown', (event) => this.#onComboboxKeyDown(event));
this.#dialog.addEventListener('click', (event) => this.#onDialogClick(event));
this.#dialog.addEventListener('keydown', (event) => this.#onDialogKeyDown(event));
this.#dialog.addEventListener('close', () => this.#onDialogClose(event));
this.#searchBar.addEventListener('input', () => this.#onSearchbarInput(event));
this.#clearButton.addEventListener('click', (event) => this.#onClearButtonClick(event));
this.#listbox.addEventListener('mouseover', (event) => this.#onListboxMouseOver(event));
this.#listbox.addEventListener('mouseup', (event) => this.#onListboxMouseUp(event));
this.#slot.addEventListener('slotchange', () => this.#onSlotChange());

this.#setProps();
Expand All @@ -538,9 +539,11 @@ class BzSelectElement extends HTMLElement {
}

/**
* Called whenever the {@link #combobox} is clicked. Show the dropdown list.
* Called whenever a mouse button is pressed on the {@link #combobox}. Show the dropdown list.
* @param {MouseEvent} event `mousedown` event.
*/
#onComboboxClick() {
#onComboboxMouseDown(event) {
event.preventDefault();
this.#showDropdown();
}

Expand Down Expand Up @@ -607,7 +610,8 @@ class BzSelectElement extends HTMLElement {

/**
* Called whenever the {@link #dialog} is clicked. Hide the dropdown list, and select a new option
* if possible.
* if possible. Usually {@link #onListboxMouseUp} handles selection, but the code is needed to
* pass the Selenium tests using `click` events.
* @param {MouseEvent} event `click` event.
*/
#onDialogClick(event) {
Expand Down Expand Up @@ -707,12 +711,32 @@ class BzSelectElement extends HTMLElement {
}

/**
* Called whenever the mouse is moved over the {@link #listbox}. the active state if possible.
* Called whenever the mouse is moved over the {@link #listbox}. Update the active state if the
* target is an option.
* @param {MouseEvent} event `mouseover` event.
*/
#onListboxMouseOver(event) {
if (event.target.matches('bz-option:not([disabled])')) {
this.#activeOption = event.target;
const { target } = event;

if (target.matches('bz-option:not([disabled])')) {
this.#activeOption = target;
}
}

/**
* Called whenever a mouse button is released on the {@link #listbox}. Select a new option if the
* target is an option.
* @param {MouseEvent} event `mouseup` event.
*/
#onListboxMouseUp(event) {
const { target } = event;

if (target.matches('bz-option:not([disabled])')) {
event.preventDefault();
this.#hideDropdown();
this.#canDispatchEvent = true;
this.value = target.value;
this.#canDispatchEvent = false;
}
}

Expand Down