Skip to content
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
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