fix(use-aria-link): onclick deprecation warning for Button as Link (#4497)

This commit is contained in:
աӄա 2025-01-05 20:33:15 +08:00 committed by GitHub
parent 33e0418d08
commit b2e924fe19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"@nextui-org/use-aria-link": patch
---
fix onclick deprecation warning for Button as Link (#4493)

View File

@ -19,6 +19,8 @@ export interface AriaLinkOptions extends AriaLinkProps {
"aria-current"?: DOMAttributes["aria-current"];
/** Whether the link is disabled. */
isDisabled?: boolean;
/** The role of the element */
role?: string;
/**
* The HTML element used to render the link, e.g. 'a', or 'span'.
* @default 'a'
@ -46,6 +48,7 @@ export function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElem
onPressEnd,
// @ts-ignore
onClick: deprecatedOnClick,
role,
isDisabled,
...otherProps
} = props;
@ -61,7 +64,7 @@ export function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElem
let isMobile = isIOS() || isAndroid();
if (deprecatedOnClick && typeof deprecatedOnClick === "function") {
if (deprecatedOnClick && typeof deprecatedOnClick === "function" && role !== "button") {
warn(
"onClick is deprecated, please use onPress instead. See: https://github.com/nextui-org/nextui/issues/4292",
"useLink",