mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(autocomplete): empty items with allowCustomValue (#2674)
* feat(autocomplete): add & export getEmptyPopoverProps * fix(autocomplete): avoid null node in `ariaHideOutside` from `@react-aria/overlays` * feat(changeset): add changeset
This commit is contained in:
parent
feab3e6c1d
commit
86a78c9b91
5
.changeset/chatty-singers-remember.md
Normal file
5
.changeset/chatty-singers-remember.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nextui-org/autocomplete": patch
|
||||
---
|
||||
|
||||
Fixed empty items with allowCustomValue by avoiding null node in `ariaHideOutside` from `@react-aria/overlays`
|
||||
@ -26,6 +26,7 @@ function Autocomplete<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLI
|
||||
getInputProps,
|
||||
getListBoxProps,
|
||||
getPopoverProps,
|
||||
getEmptyPopoverProps,
|
||||
getClearButtonProps,
|
||||
getListBoxWrapperProps,
|
||||
getEndContentWrapperProps,
|
||||
@ -42,7 +43,9 @@ function Autocomplete<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLI
|
||||
<Listbox {...getListBoxProps()} />
|
||||
</ScrollShadow>
|
||||
</FreeSoloPopover>
|
||||
) : null;
|
||||
) : (
|
||||
<div {...getEmptyPopoverProps()} />
|
||||
);
|
||||
|
||||
return (
|
||||
<Component {...getBaseProps()}>
|
||||
|
||||
@ -400,6 +400,14 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
|
||||
} as unknown as PopoverProps;
|
||||
};
|
||||
|
||||
const getEmptyPopoverProps = () => {
|
||||
// avoid null node in `ariaHideOutside` from `@react-aria/overlays`
|
||||
return {
|
||||
ref: popoverRef,
|
||||
classNames: "hidden",
|
||||
};
|
||||
};
|
||||
|
||||
const getListBoxWrapperProps: PropGetter = (props: any = {}) => ({
|
||||
...mergeProps(slotsProps.scrollShadowProps, props),
|
||||
className: slots.listboxWrapper({
|
||||
@ -443,6 +451,7 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
|
||||
getInputProps,
|
||||
getListBoxProps,
|
||||
getPopoverProps,
|
||||
getEmptyPopoverProps,
|
||||
getClearButtonProps,
|
||||
getSelectorButtonProps,
|
||||
getListBoxWrapperProps,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user