Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: forwardRef render functions not using ref #4198

Merged
merged 5 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/sharp-years-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@nextui-org/dropdown": patch
"@nextui-org/listbox": patch
"@nextui-org/menu": patch
"@nextui-org/modal": patch
"@nextui-org/popover": patch
---

Fix forwardRef render functions not using ref
5 changes: 2 additions & 3 deletions packages/components/dropdown/src/dropdown-trigger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {forwardRef} from "@nextui-org/system";
import {PopoverTrigger} from "@nextui-org/popover";

import {useDropdownContext} from "./dropdown-context";
Expand All @@ -11,13 +10,13 @@ export interface DropdownTriggerProps {
* DropdownTrigger opens the popover's content. It must be an interactive element
* such as `button` or `a`.
*/
const DropdownTrigger = forwardRef<"button", DropdownTriggerProps>((props, _) => {
const DropdownTrigger = (props: DropdownTriggerProps) => {
const {getMenuTriggerProps} = useDropdownContext();

const {children, ...otherProps} = props;

return <PopoverTrigger {...getMenuTriggerProps(otherProps)}>{children}</PopoverTrigger>;
});
};

DropdownTrigger.displayName = "NextUI.DropdownTrigger";

Expand Down
5 changes: 2 additions & 3 deletions packages/components/listbox/src/listbox-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {useMemo, ReactNode} from "react";
import {forwardRef} from "@nextui-org/system";

import {UseListboxItemProps, useListboxItem} from "./use-listbox-item";
import {ListboxSelectedIcon} from "./listbox-selected-icon";
Expand All @@ -9,7 +8,7 @@ export interface ListboxItemProps<T extends object = object> extends UseListboxI
/**
* @internal
*/
const ListboxItem = forwardRef<"li", ListboxItemProps>((props, _) => {
const ListboxItem = (props: ListboxItemProps) => {
const {
Component,
FragmentWrapper,
Expand Down Expand Up @@ -64,7 +63,7 @@ const ListboxItem = forwardRef<"li", ListboxItemProps>((props, _) => {
</FragmentWrapper>
</Component>
);
});
};

ListboxItem.displayName = "NextUI.ListboxItem";

Expand Down
6 changes: 2 additions & 4 deletions packages/components/menu/src/menu-item.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {useMemo, ReactNode} from "react";
import {forwardRef} from "@nextui-org/system";
import * as React from "react";

import {UseMenuItemProps, useMenuItem} from "./use-menu-item";
import {MenuSelectedIcon} from "./menu-selected-icon";
Expand All @@ -10,7 +8,7 @@ export interface MenuItemProps<T extends object = object> extends UseMenuItemPro
/**
* @internal
*/
const MenuItem = forwardRef<"li", MenuItemProps>((props, _) => {
const MenuItem = (props: MenuItemProps) => {
const {
Component,
FragmentWrapper,
Expand Down Expand Up @@ -69,7 +67,7 @@ const MenuItem = forwardRef<"li", MenuItemProps>((props, _) => {
</FragmentWrapper>
</Component>
);
});
};

MenuItem.displayName = "NextUI.MenuItem";

Expand Down
5 changes: 2 additions & 3 deletions packages/components/modal/src/modal-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {AriaDialogProps} from "@react-aria/dialog";
import type {HTMLMotionProps} from "framer-motion";

import {cloneElement, isValidElement, ReactNode, useMemo, useCallback} from "react";
import {forwardRef} from "@nextui-org/system";
import {DismissButton} from "@react-aria/overlays";
import {TRANSITION_VARIANTS} from "@nextui-org/framer-utils";
import {CloseIcon} from "@nextui-org/shared-icons";
Expand All @@ -23,7 +22,7 @@ export interface ModalContentProps extends AriaDialogProps, HTMLNextUIProps<"div

const domAnimation = () => import("@nextui-org/dom-animation").then((res) => res.default);

const ModalContent = forwardRef<"div", ModalContentProps, KeysToOmit>((props, _) => {
const ModalContent = (props: ModalContentProps) => {
const {as, children, role = "dialog", ...otherProps} = props;

const {
Expand Down Expand Up @@ -139,7 +138,7 @@ const ModalContent = forwardRef<"div", ModalContentProps, KeysToOmit>((props, _)
{contents}
</div>
);
});
};

ModalContent.displayName = "NextUI.ModalContent";

Expand Down
5 changes: 2 additions & 3 deletions packages/components/popover/src/popover-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {AriaDialogProps} from "@react-aria/dialog";
import type {HTMLMotionProps} from "framer-motion";

import {DOMAttributes, ReactNode, useMemo, useRef} from "react";
import {forwardRef} from "@nextui-org/system";
import {RemoveScroll} from "react-remove-scroll";
import {DismissButton} from "@react-aria/overlays";
import {TRANSITION_VARIANTS} from "@nextui-org/framer-utils";
Expand All @@ -21,7 +20,7 @@ export interface PopoverContentProps

const domAnimation = () => import("@nextui-org/dom-animation").then((res) => res.default);

const PopoverContent = forwardRef<"div", PopoverContentProps>((props, _) => {
const PopoverContent = (props: PopoverContentProps) => {
const {as, children, className, ...otherProps} = props;

const {
Expand Down Expand Up @@ -113,7 +112,7 @@ const PopoverContent = forwardRef<"div", PopoverContentProps>((props, _) => {
{contents}
</div>
);
});
};

PopoverContent.displayName = "NextUI.PopoverContent";

Expand Down
5 changes: 2 additions & 3 deletions packages/components/popover/src/popover-trigger.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {Children, cloneElement, useMemo} from "react";
import {forwardRef} from "@nextui-org/system";
import {pickChildren} from "@nextui-org/react-utils";
import {useAriaButton} from "@nextui-org/use-aria-button";
import {Button} from "@nextui-org/button";
Expand All @@ -15,7 +14,7 @@ export interface PopoverTriggerProps {
* PopoverTrigger opens the popover's content. It must be an interactive element
* such as `button` or `a`.
*/
const PopoverTrigger = forwardRef<"button", PopoverTriggerProps>((props, _) => {
const PopoverTrigger = (props: PopoverTriggerProps) => {
const {triggerRef, getTriggerProps} = usePopoverContext();

const {children, ...otherProps} = props;
Expand Down Expand Up @@ -50,7 +49,7 @@ const PopoverTrigger = forwardRef<"button", PopoverTriggerProps>((props, _) => {
child,
mergeProps(restProps, hasNextUIButton ? {onPress, isDisabled} : buttonProps),
);
});
};

PopoverTrigger.displayName = "NextUI.PopoverTrigger";

Expand Down
Loading