Skip to content

Commit

Permalink
Merge pull request #9049 from robojumper/fix-combobox-regression
Browse files Browse the repository at this point in the history
Work around downshift+autofocus regression
  • Loading branch information
bhollis authored Feb 3, 2023
2 parents e8b1a88 + 5685332 commit bb6ed08
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/search/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ function SearchBar(
) {
const { type, changes } = actionAndChanges;
switch (type) {
// FIXME: Do not act on focus because it interacts badly with autofocus
// Downshift will likely switch away from using focus because too
// https://github.com/downshift-js/downshift/issues/1439
// (Also see onFocus below)
case useCombobox.stateChangeTypes.InputFocus:
return state;
case useCombobox.stateChangeTypes.ItemClick:
case useCombobox.stateChangeTypes.InputKeyDownEnter:
// exit early if non FilterHelper item was selected
Expand All @@ -316,14 +322,15 @@ function SearchBar(
return {
...changes,
selectedItem: state.selectedItem, // keep the last selected item (i.e. the edit field stays unchanged)
closeMenu: true, // close the menu
};

default:
return changes; // no handling for other types
}
}

// FIXME: Maybe follow suit when Downshift changes opening behavior to
// just use clicks and not focus (see stateReducer above)
const onFocus = () => {
if (!liveQuery && !isOpen && !autoFocus) {
openMenu();
Expand Down

0 comments on commit bb6ed08

Please # to comment.