From 780ba43162dc7ceb3f7b46c68c8134473013c873 Mon Sep 17 00:00:00 2001 From: Alex Nguyen Date: Sat, 5 Oct 2024 18:18:29 +1300 Subject: [PATCH] fix(autocomplete): exit animation on popover close (#3845) * fix(autocomplete): exit animation on popover close * refactor(autocomplete): getListBoxProps --------- Co-authored-by: WK Wong --- .changeset/mighty-birds-deny.md | 5 +++++ packages/components/autocomplete/src/autocomplete.tsx | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/mighty-birds-deny.md diff --git a/.changeset/mighty-birds-deny.md b/.changeset/mighty-birds-deny.md new file mode 100644 index 0000000000..b991ace2ff --- /dev/null +++ b/.changeset/mighty-birds-deny.md @@ -0,0 +1,5 @@ +--- +"@nextui-org/autocomplete": patch +--- + +Return null if there are items for exit animation on popover close to work diff --git a/packages/components/autocomplete/src/autocomplete.tsx b/packages/components/autocomplete/src/autocomplete.tsx index 2eadca4ebd..ba434fe292 100644 --- a/packages/components/autocomplete/src/autocomplete.tsx +++ b/packages/components/autocomplete/src/autocomplete.tsx @@ -31,15 +31,17 @@ function Autocomplete(props: Props, ref: ForwardedRef({...props, ref}); + const listboxProps = getListBoxProps(); + const popoverContent = isOpen ? ( - + - ) : ( + ) : listboxProps.state?.collection.size === 0 ? (
- ); + ) : null; return (