Skip to content

Commit

Permalink
Clear inputValue on the background to avoid suggestion flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
zaguiini committed Sep 12, 2024
1 parent 2a62872 commit 43158d2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/components/src/combobox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ function ComboboxControl( props: ComboboxControlProps ) {
const [ inputValue, setInputValue ] = useState( '' );
const inputContainer = useRef< HTMLInputElement >( null );

useEffect( () => {
if ( ! inputHasFocus ) {
setInputValue( '' );
}
}, [ inputHasFocus ] );

const matchingSuggestions = useMemo( () => {
const startsWithMatch: ComboboxControlOption[] = [];
const containsMatch: ComboboxControlOption[] = [];
Expand Down Expand Up @@ -238,8 +244,6 @@ function ComboboxControl( props: ComboboxControlProps ) {
if ( ! currentOption ) {
onFilterValueChange( '' );
}

setInputValue( '' );
};

const onFocus = () => {
Expand Down

0 comments on commit 43158d2

Please sign in to comment.