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

Ctrl/cmd click does not open in a new tab/window #2383

Open
1 of 3 tasks
rogusdev opened this issue May 2, 2024 · 0 comments
Open
1 of 3 tasks

Ctrl/cmd click does not open in a new tab/window #2383

rogusdev opened this issue May 2, 2024 · 0 comments

Comments

@rogusdev
Copy link
Sponsor Contributor

rogusdev commented May 2, 2024

Problem

Link elements are a tags in rendered html, but have a dioxus-prevent-default="onclick" which I assume is not looking at the ctrl/cmd state when clicked to replicate the normal browser behavior. https://support.mozilla.org/en-US/questions/1336268 is a discussion of this problem in general (dioxus is not the first and only framework with this issue, but it is fixable.)

If you are not familiar with this workflow: ctrl clicking a "normal" link on the vast majority of websites will open the link in a new browser tab/window, but not so with Link elements in a current dioxus site. Consistency with typical browser behavior/usage seems desirable. (Thus this issue is being tagged as a bug rather than feature request.)

It's easy enough to find where normal link behavior is blocked:

.get_attribute("dioxus-prevent-default")

And I believe this is where link clicking is replaced:

if do_default && is_router_nav {

But I'm not sure how quite to work with the router and/or browser to handle this behavior properly on the web -- especially given dioxus's cross platform nature of desktop vs web, etc where ctrl click opening a new tab perhaps does not make sense except only in a browser. It seems like some kind of override is needed for web to handle this consistently with that the typical behavior unique for that platform (browsers). Given pointers on where the appropriate (i.e. acceptable to the team) place to make such an override would be, I'll happily attempt to make the changes myself.

Steps To Reproduce

  • dx new with router
  • dx serve that new app
  • open up http://localhost:8080/
  • ctrl click the "Go to blog" link at the top

Expected behavior

Ctrl clicking the "Go to blog" link should open in a new tab/window (depending on your browser config).

For comparison, go to https://www.google.com/ and ctrl click the "About" link in the top left, it will open in a new tab/window.

Environment:

  • App platform: web

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@rogusdev rogusdev changed the title Ctrl click does not open in a new tab/window Ctrl/cmd click does not open in a new tab/window May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant