mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
dropdown_list_widget: Properly bind focus event to input field.
Previously, the focus event was triggering on a hidden dropdown input field, which caused it to not gain focus when clicked on dropdown button. This is so because focus events cannot be triggered to hidden elements or elements that aren't visible in DOM. Added a fix by explicilty triggering the focus event to dropdown input field only if the input field is visible in the DOM.
This commit is contained in:
committed by
Tim Abbott
parent
a3baf90d3a
commit
2c50c67d07
@@ -119,7 +119,13 @@ export const DropdownListWidget = function ({
|
||||
// On opening a Bootstrap Dropdown, the parent element receives focus.
|
||||
// Here, we want our search input to have focus instead.
|
||||
e.preventDefault();
|
||||
search_input.trigger("focus");
|
||||
// This function gets called twice when focusing the
|
||||
// dropdown, and only in the second call is the input
|
||||
// field visible in the DOM; so the following visibility
|
||||
// check ensures we wait for the second call to focus.
|
||||
if (dropdown_list_body.is(":visible")) {
|
||||
search_input.trigger("focus");
|
||||
}
|
||||
});
|
||||
|
||||
search_input.on("keydown", (e) => {
|
||||
|
||||
Reference in New Issue
Block a user