Skip to content

Commit ba54b80

Browse files
committed
chore: remove unnecessary initialization logic
1 parent 93c7179 commit ba54b80

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

packages/pluggableWidgets/combobox-web/src/hooks/useDownshiftSingleSelectProps.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
useCombobox
88
} from "downshift";
99

10-
import { useCallback, useMemo, useRef, useEffect } from "react";
10+
import { useCallback, useMemo } from "react";
1111
import { A11yStatusMessage, SingleSelector } from "../helpers/types";
1212

1313
interface Options {
@@ -21,11 +21,6 @@ export function useDownshiftSingleSelectProps(
2121
a11yStatusMessage: A11yStatusMessage
2222
): UseComboboxReturnValue<string> {
2323
const { inputId, labelId } = options;
24-
const isInitializing = useRef(true);
25-
26-
useEffect(() => {
27-
isInitializing.current = false;
28-
}, []);
2924

3025
const downshiftProps: UseComboboxProps<string> = useMemo(() => {
3126
return {
@@ -34,13 +29,9 @@ export function useDownshiftSingleSelectProps(
3429
onSelectedItemChange({ selectedItem }: UseComboboxStateChange<string>) {
3530
selector.setValue(selectedItem ?? null);
3631
},
37-
onInputValueChange({ inputValue, type }) {
32+
onInputValueChange({ inputValue }) {
3833
selector.options.setSearchTerm(inputValue!);
39-
if (
40-
!isInitializing.current &&
41-
type === useCombobox.stateChangeTypes.InputChange &&
42-
selector.onFilterInputChange
43-
) {
34+
if (selector.onFilterInputChange) {
4435
selector.onFilterInputChange(inputValue!);
4536
}
4637
},

0 commit comments

Comments
 (0)