Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions .changeset/tough-spies-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@nextui-org/autocomplete": patch
"@nextui-org/dropdown": patch
"@nextui-org/popover": patch
"@nextui-org/tooltip": patch
Comment on lines +2 to +5
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wingkwong why are we upgrading packages outside the autocomplete one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrgarciadev changeset shows these are changed tho, or I just include autocomplete one?

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's include all the changed packages "just in case", but it should only detect the autocomplete

---

fix(autocomplete): support isReadOnly for dynamic collections in Autocomplete
12 changes: 8 additions & 4 deletions packages/components/autocomplete/src/use-autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,12 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
// Setup filter function and state.
const {contains} = useFilter(filterOptions);

const state = useComboBoxState({
let state = useComboBoxState({
...originalProps,
children,
menuTrigger,
shouldCloseOnBlur,
allowsEmptyCollection,
...(isReadOnly && {
disabledKeys: (children as unknown as Record<string, any>[]).map((o) => o.key),
}),
defaultFilter: defaultFilter && typeof defaultFilter === "function" ? defaultFilter : contains,
onOpenChange: (open, menuTrigger) => {
onOpenChange?.(open, menuTrigger);
Expand All @@ -181,6 +178,13 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
},
});

state = {
...state,
...(isReadOnly && {
disabledKeys: new Set([...state.collection.getKeys()].map((k) => k)),
}),
};

// Setup refs and get props for child elements.
const buttonRef = useRef<HTMLButtonElement>(null);
const inputWrapperRef = useRef<HTMLDivElement>(null);
Expand Down