mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(popover): isDisabled prop on a DOM element (#2741)
* fix(popover): isDisabled prop on a DOM element * refactor(popover): filter non-react props * fix(dropdown): tests --------- Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>
This commit is contained in:
parent
6b56e43a35
commit
f89356691c
5
.changeset/hot-paws-smell.md
Normal file
5
.changeset/hot-paws-smell.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nextui-org/popover": patch
|
||||
---
|
||||
|
||||
Fixes isDisabled prop on a DOM element
|
||||
@ -109,6 +109,7 @@ describe("Dropdown", () => {
|
||||
items={section.children}
|
||||
title={section.title}
|
||||
>
|
||||
{/* @ts-ignore */}
|
||||
{(item: any) => <DropdownItem key={item.key}>{item.name}</DropdownItem>}
|
||||
</DropdownSection>
|
||||
)}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, {Children, cloneElement, useMemo} from "react";
|
||||
import {forwardRef, isNextUIEl} from "@nextui-org/system";
|
||||
import {pickChildren, filterDOMProps} from "@nextui-org/react-utils";
|
||||
import {filterDOMProps, 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,18 +42,11 @@ const PopoverTrigger = forwardRef<"button", PopoverTriggerProps>((props, _) => {
|
||||
return triggerChildren?.[0] !== undefined;
|
||||
}, [triggerChildren]);
|
||||
|
||||
const isDisabled = !!restProps?.isDisabled;
|
||||
|
||||
const isNextUIElement = isNextUIEl(child);
|
||||
|
||||
return cloneElement(
|
||||
child,
|
||||
mergeProps(
|
||||
// if we add `isDisabled` prop to DOM elements,
|
||||
// react will fail to recognize it on a DOM element,
|
||||
// hence, apply filterDOMProps for such case
|
||||
filterDOMProps(restProps, {
|
||||
enabled: isDisabled && !isNextUIElement,
|
||||
enabled: !isNextUIEl(child),
|
||||
}),
|
||||
hasNextUIButton ? {onPress} : buttonProps,
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user