Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Links open in both tauri and system browser #154

Open
mattyg opened this issue Apr 20, 2023 · 3 comments
Open

Links open in both tauri and system browser #154

mattyg opened this issue Apr 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@mattyg
Copy link
Member

mattyg commented Apr 20, 2023

Describe the bug
It looks like launcher is intercepting anchor tag clicks and opening them with the system browser if they start with http:// or https:// and don't contain tauri.localhost (here: https://github.com/holochain/launcher/blob/d39785209d600e24782874da2ea0847707dd9228/crates/holochain_launcher_utils/src/window_builder.rs#L44)

My issue is every time I click a link it opens both in the tauri window, and in my system browser simultaneously. I think it only occurs when running in a dev environment, since links are not replaced with tauri.localhost.

In general though, I wonder if it makes more sense to rely on the html attribute target="_blank" to distinguish links that should be opened in the system browser versus tauri, since that's already the convention for links opening in a new window.

To Reproduce

  • create a ui with a link <a href="/otherpage">link</a>
  • launch the app with hc launch
  • click the link
    (link opens in browser as well as in tauri)

Expected behavior
A link should either open in tauri, or in the browser, but not both. This should be consistent between built happs and happs in a development environment. Ideally developers should be able to specify which links we want opened in the system browser with target="_blank"

Logs
n/a

Screenshots
n/a

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Holochain Launcher Version: hc launch 0.0.12

Additional context
n/a

@mattyg mattyg added the bug Something isn't working label Apr 20, 2023
@mattyg mattyg changed the title Use target="_blank" to distinguish links that should open outside of tauri Links open in both tauri and system browser Apr 20, 2023
@matthme
Copy link
Collaborator

matthme commented May 2, 2023

Sorry for the late response. I cannot actually reproduce this...(I have an app where I explicitly test this and other functionality, you can see it here. The steps you describe to reproduce it behave as expected for me with hc launch 0.0.12, no opening in a system browser. And actual http(s) url's only open in the system browser, not in the tauri window. Do you have an idea where our examples may differ?

Regarding taking the target="_blank" into account (if provided): Do you see any use case of ever opening an http(s) link in the tauri window directly? I personally had the impression that this is quite confusing because there is no intuitive way to get back to the app in that case (only via right click > back) so I thought it makes sense to just have opening http(s) links in the system browser be the default in any case. And any non-http(s) links should anyway be opened in the tauri window directly, at least that's intended behavior.

@mattyg
Copy link
Member Author

mattyg commented May 3, 2023

okay I'll see if I can make a reproduction. It may be related to vue-router rendering its <RouterLink> component with the full path, or using launcher with the --ui-port option.

@mattyg
Copy link
Member Author

mattyg commented May 3, 2023

Regarding taking the target="_blank" into account (if provided): Do you see any use case of ever opening an http(s) link in the tauri window directly? I personally had the impression that this is quite confusing because there is no intuitive way to get back to the app in that case (only via right click > back) so I thought it makes sense to just have opening http(s) links in the system browser be the default in any case. And any non-http(s) links should anyway be opened in the tauri window directly, at least that's intended behavior.

Yeah, my only reason is for this issue I'm running into, and that it's already convention for links, but let's see if we can resolve the issue another way. I think you're right that there's probably no case where you'd want to open an http link inside the tauri window.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants