dropdown_list_widget: Select first option on pressing enter in search.

This commit updates the code for MultiSelectDropdownListWidget and
DropdownListWidget components to select the first option on pressing
enter when focus is on search input.

Fixes #25024.
This commit is contained in:
Sahil Batra 2023-04-07 16:46:05 +05:30 committed by Tim Abbott
parent fc251fd464
commit 35433c02b3
1 changed files with 16 additions and 0 deletions

View File

@ -201,6 +201,14 @@ export class DropdownListWidget {
break;
}
}
if (keydown_util.is_enter_event(e) && e.target === $search_input[0]) {
e.stopPropagation();
e.preventDefault();
// Select the first option from the menu on pressing
// "Enter" when focus is on the search input.
dropdown_elements().first().trigger("click");
}
});
}
@ -525,6 +533,14 @@ export class MultiSelectDropdownListWidget extends DropdownListWidget {
break;
}
}
if (keydown_util.is_enter_event(e) && e.target === $search_input[0]) {
e.stopPropagation();
e.preventDefault();
// Select the first option from the menu on pressing
// "Enter" when focus is on the search input.
dropdown_elements().first().trigger("click");
}
});
}