You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case for a link which, for accessibility and UX reasons, I want to be rendered as an anchor with a href (i.e. I want it to semantically appear as a link and I want all the context menu / middle click behaviors of a link). However, if pressing the link within the SPA, I want to perform some animations before I actually trigger the route change.
I currently cannot do this with react-aria-components because there is no way to preventDefault on the event passed to the onPress handler.
Note this isn't specific to just Links, it also applies to other items that have navigation functionality and render anchors, e.g. tabs, etc
🤔 Expected Behavior?
Some way to override the client navigation behavior -- or at least defer the execution of it
😯 Current Behavior
No way to override client navigation behavior / defer execution
💁 Possible Solution
Do not use a <Link />; use a <Button /> instead. This sucks though because it's semantically incorrect and prevents the browser from giving you things like the right-click context menu and ctrl-click to open in a new tab.
Do not use react-aria-components for this link, maybe drop down to the react-aria hooks directly; that feels like an unnecessarily painful solution to something that could easily be solved with any of a number of possible API tweaks to the link component.
🔦 Context
I think it's all provided above.
💻 Examples
I have a few possible ideas for solutions:
If onPress returns a promise, then await it before triggering client-side navigation:
For any react-aria maintainers: I'm more than happy to contribute a PR to fix this if you all would help advise me on which solution would be accepted!
Provide a general summary of the feature here
I have a use case for a link which, for accessibility and UX reasons, I want to be rendered as an anchor with a href (i.e. I want it to semantically appear as a link and I want all the context menu / middle click behaviors of a link). However, if pressing the link within the SPA, I want to perform some animations before I actually trigger the route change.
I currently cannot do this with
react-aria-components
because there is no way topreventDefault
on the event passed to theonPress
handler.Note this isn't specific to just Links, it also applies to other items that have navigation functionality and render anchors, e.g. tabs, etc
🤔 Expected Behavior?
Some way to override the client navigation behavior -- or at least defer the execution of it
😯 Current Behavior
No way to override client navigation behavior / defer execution
💁 Possible Solution
<Link />
; use a<Button />
instead. This sucks though because it's semantically incorrect and prevents the browser from giving you things like the right-click context menu and ctrl-click to open in a new tab.react-aria-components
for this link, maybe drop down to thereact-aria
hooks directly; that feels like an unnecessarily painful solution to something that could easily be solved with any of a number of possible API tweaks to the link component.🔦 Context
I think it's all provided above.
💻 Examples
I have a few possible ideas for solutions:
onPress
returns a promise, then await it before triggering client-side navigation:preventDefault
:🧢 Your Company/Team
Douro Labs
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: