mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(popover): ref not beign passed
This commit is contained in:
parent
69f713cb05
commit
9e5dd8ce37
5
.changeset/mean-days-smell.md
Normal file
5
.changeset/mean-days-smell.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nextui-org/popover": patch
|
||||
---
|
||||
|
||||
Fix ref not beign passed
|
||||
@ -1,6 +1,6 @@
|
||||
import React, {Children, cloneElement, useMemo} from "react";
|
||||
import {forwardRef, isNextUIEl} from "@nextui-org/system";
|
||||
import {filterDOMProps, pickChildren} from "@nextui-org/react-utils";
|
||||
import {pickChildren} from "@nextui-org/react-utils";
|
||||
import {useAriaButton} from "@nextui-org/use-aria-button";
|
||||
import {Button} from "@nextui-org/button";
|
||||
import {mergeProps} from "@react-aria/utils";
|
||||
@ -42,15 +42,14 @@ const PopoverTrigger = forwardRef<"button", PopoverTriggerProps>((props, _) => {
|
||||
return triggerChildren?.[0] !== undefined;
|
||||
}, [triggerChildren]);
|
||||
|
||||
return cloneElement(
|
||||
child,
|
||||
mergeProps(
|
||||
filterDOMProps(restProps, {
|
||||
enabled: !isNextUIEl(child),
|
||||
}),
|
||||
hasNextUIButton ? {onPress} : buttonProps,
|
||||
),
|
||||
);
|
||||
const isNextUIElement = isNextUIEl(child);
|
||||
|
||||
// `isDisabled` is added in `getMenuTriggerProps()` in `use-dropdown.ts`.
|
||||
// if we include `isDisabled` prop in a DOM element, react will fail to recognize it on a DOM element.
|
||||
// hence, apply filterDOMProps for such case
|
||||
if (!isNextUIElement) delete restProps["isDisabled"];
|
||||
|
||||
return cloneElement(child, mergeProps(restProps, hasNextUIButton ? {onPress} : buttonProps));
|
||||
});
|
||||
|
||||
PopoverTrigger.displayName = "NextUI.PopoverTrigger";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user