Skip to content

Commit

Permalink
fix(autocomplete): exit animation on popover close (#3845)
Browse files Browse the repository at this point in the history
* fix(autocomplete): exit animation on popover close

* refactor(autocomplete): getListBoxProps

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>
  • Loading branch information
alexnguyennz and wingkwong authored Oct 5, 2024
1 parent 781b855 commit 780ba43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-birds-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/autocomplete": patch
---

Return null if there are items for exit animation on popover close to work
8 changes: 5 additions & 3 deletions packages/components/autocomplete/src/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ function Autocomplete<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLI
getEndContentWrapperProps,
} = useAutocomplete<T>({...props, ref});

const listboxProps = getListBoxProps();

const popoverContent = isOpen ? (
<FreeSoloPopover {...getPopoverProps()}>
<ScrollShadow {...getListBoxWrapperProps()}>
<Listbox {...getListBoxProps()} />
<Listbox {...listboxProps} />
</ScrollShadow>
</FreeSoloPopover>
) : (
) : listboxProps.state?.collection.size === 0 ? (
<div {...getEmptyPopoverProps()} />
);
) : null;

return (
<Component {...getBaseProps()}>
Expand Down

0 comments on commit 780ba43

Please sign in to comment.