holochain / launcher-tauri

Desktop launcher to install and use Holochain apps locally
262 stars 21 forks source link

Links open in both tauri and system browser #154

Open mattyg opened 1 year ago

mattyg commented 1 year ago

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

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):

Additional context n/a

matthme commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.