Skip to content

Commit

Permalink
fix(use-aria-link): onclick deprecation warning for Button as Link
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Jan 5, 2025
1 parent a43b156 commit a80d563
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sixty-fireants-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/use-aria-link": patch
---

fix onclick deprecation warning for Button as Link (#4493)
5 changes: 4 additions & 1 deletion packages/hooks/use-aria-link/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -46,6 +48,7 @@ export function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElem
onPressEnd,
// @ts-ignore
onClick: deprecatedOnClick,
role,
isDisabled,
...otherProps
} = props;
Expand All @@ -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",
Expand Down

0 comments on commit a80d563

Please sign in to comment.