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(system): listbox href issue #3119

Merged
merged 16 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
6 changes: 6 additions & 0 deletions .changeset/fast-ladybugs-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/system": patch
"@nextui-org/link": patch
---

Fixed listbox href issue (#3105)
2 changes: 1 addition & 1 deletion packages/components/link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@nextui-org/shared-icons": "workspace:*",
"@nextui-org/react-utils": "workspace:*",
"@nextui-org/use-aria-link": "workspace:*",
"@react-aria/link": "3.6.5",
"@react-aria/link": "3.7.1",
"@react-aria/utils": "3.23.2",
"@react-aria/focus": "3.16.2",
"@react-types/link": "3.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/link/src/use-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {AriaLinkProps} from "@react-types/link";
import type {LinkVariantProps} from "@nextui-org/theme";

import {link} from "@nextui-org/theme";
import {useAriaLink} from "@nextui-org/use-aria-link";
import {useLink as useAriaLink} from "@react-aria/link";
import {
HTMLNextUIProps,
mapPropsVariants,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@react-aria/i18n": "3.10.2",
"@internationalized/date": "^3.5.2",
"@react-aria/overlays": "3.21.1",
"@react-aria/utils": "3.23.2",
"@react-aria/utils": "3.24.1",
"@react-stately/utils": "3.9.1"
}
}
4 changes: 2 additions & 2 deletions packages/hooks/use-aria-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"dependencies": {
"@react-aria/focus": "3.16.2",
"@react-aria/interactions": "3.21.1",
"@react-aria/utils": "3.23.2",
"@react-types/link": "3.5.3",
"@react-aria/utils": "3.24.1",
"@react-types/link": "3.5.5",
"@react-types/shared": "3.22.1"
},
"devDependencies": {
Expand Down
16 changes: 12 additions & 4 deletions packages/hooks/use-aria-link/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import {AriaLinkProps} from "@react-types/link";
import {DOMAttributes, FocusableElement} from "@react-types/shared";
import {filterDOMProps, mergeProps, useRouter, shouldClientNavigate} from "@react-aria/utils";
import {
filterDOMProps,
mergeProps,
useRouter,
shouldClientNavigate,
useLinkProps,
} from "@react-aria/utils";
import {RefObject} from "react";
import {useFocusable} from "@react-aria/focus";
import {usePress} from "@react-aria/interactions";
Expand Down Expand Up @@ -54,10 +60,11 @@ export function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElem
let domProps = filterDOMProps(otherProps, {labelable: true, isLink: elementType === "a"});
let interactionHandlers = mergeProps(focusableProps, pressProps);
let router = useRouter();
let routerLinkProps = useLinkProps(props);

return {
isPressed, // Used to indicate press state for visual
linkProps: mergeProps(domProps, {
linkProps: mergeProps(domProps, routerLinkProps, {
...interactionHandlers,
...linkProps,
"aria-disabled": isDisabled || undefined,
Expand All @@ -75,10 +82,11 @@ export function useAriaLink(props: AriaLinkOptions, ref: RefObject<FocusableElem
e.currentTarget.href &&
// If props are applied to a router Link component, it may have already prevented default.
!e.isDefaultPrevented() &&
shouldClientNavigate(e.currentTarget, e)
shouldClientNavigate(e.currentTarget, e) &&
props.href
) {
e.preventDefault();
router.open(e.currentTarget, e);
router.open(e.currentTarget, e, props.href, props.routerOptions);
}
},
}),
Expand Down
118 changes: 103 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading