-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
feat: unstable_defaultAltClick link prop, no route change if enabled #1249
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
I think this is a draft until we create an e2e test. |
ed3d6aa
to
08e2b4d
Compare
if (!isAltClick) { | ||
event.preventDefault(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can it be this?
if (isAltClick) {
return;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That skips the onClick prop. What do you think about firing the onClick prop first? React Router does that and then doesn't run the internal handler if the onClick calls preventDefault().
https://github.com/remix-run/react-router/blob/react-router%407.2.0/packages/react-router/lib/dom/lib.tsx#L628-L635
function handleClick(
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
) {
if (onClick) onClick(event);
if (!event.defaultPrevented) {
internalOnClick(event);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that looks great. Any drawbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can think of. It looks good to me. I'm traveling for the next few days so I probably won't push another update until the beginning of next week.
Fixes #1248.