Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/select all crashes #3428

Merged
merged 2 commits into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,6 @@ function AutocompleteInner<T>(
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)
Expand Down Expand Up @@ -446,6 +438,14 @@ function AutocompleteInner<T>(
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
Expand Down Expand Up @@ -726,12 +726,6 @@ function AutocompleteInner<T>(
reset: resetCombobox,
} = useCombobox(comboBoxProps)

useEffect(() => {
if (isControlled) {
setSelectedItems(selectedOptions)
}
}, [isControlled, selectedOptions, setSelectedItems])

const { x, y, refs, update, strategy } = useFloating<HTMLInputElement>({
placement: 'bottom-start',
middleware: [
Expand Down
Loading