diff --git a/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx b/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx index 801345befb..f04529bc59 100644 --- a/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx +++ b/packages/eds-core-react/src/components/Autocomplete/Autocomplete.tsx @@ -367,14 +367,6 @@ function AutocompleteInner( return _availableItems }, [_availableItems, showSelectAll]) - const toggleAllSelected = () => { - if (selectedItems.length === inputOptions.length) { - setSelectedItems([]) - } else { - setSelectedItems(inputOptions) - } - } - useEffect(() => { const availableHash = JSON.stringify(inputOptions) const optionsHash = JSON.stringify(options) @@ -446,6 +438,14 @@ function AutocompleteInner( return 'NONE' }, [inputOptions, selectedItems]) + const toggleAllSelected = () => { + if (selectedItems.length === inputOptions.length) { + setSelectedItems([]) + } else { + setSelectedItems(inputOptions) + } + } + const getLabel = useCallback( (item: T) => { //note: non strict check for null or undefined to allow 0 @@ -726,12 +726,6 @@ function AutocompleteInner( reset: resetCombobox, } = useCombobox(comboBoxProps) - useEffect(() => { - if (isControlled) { - setSelectedItems(selectedOptions) - } - }, [isControlled, selectedOptions, setSelectedItems]) - const { x, y, refs, update, strategy } = useFloating({ placement: 'bottom-start', middleware: [