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(use-aria-link): onclick deprecation warning for Button as Link #4497

Merged
merged 1 commit into from
Jan 5, 2025
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
Loading