Open oliwoodsuk opened 7 months ago
What we ended up doing is creating a helper that wraps paths or URLs with the right attributes. Something like this:
<%= link_to 'Example', with_params_for_new_tab(example_path) %>
. And we used only in select links that users might be more inclined to open in new tabs, like top navigation, etc.
Another more intrusive alternative that catches all links, is to override your path and URL helpers in your authenticated controllers, to include the params by default.
But yeah, it would be nice to have a default helper for this in the gem.
@flavio-b ok cool, so at least it's not just me missing something in the gem.
Mm, I think the link_to
approach is less dirty for sure. We'll probably stick with the JS approach for now though.
The JS code above needed some tweaks for cases like anchor links and javascript:void
.
Hi @oliwoodsuk, thank you for opening this issue! This is a great suggestion, the team is going to review it and look into it.
Overview
I spent a day or so yesterday trying to figure out what the best way to support the scenario where a user command-clicks a link, so it opens in a new tab from within an embedded app.
We were previously on
v18.1.2
of this gem, and it seemed to be handled natively by the gem when theShopifyApp::EnsureAuthenticatedLinks
concern was included. Whilst inv21.8.0
of this gem, that concern adds support for deep links, it doesn't add support for opening pages in new tabs. However, it does work if ashop
andhost
param is present on the request URL. If I'm remembering correctly from yesterday, it looked likeShopifyAPI::Auth
was responsible for part of this behaviour.So my question is, is there a way native to this gem that allows us to support opening links in new tabs? We're currently solving this by dynamically adding the params to
<a>
href
s from stored.window
attributes via JS. This seems a bit hacky, maybe there's some kind of header support that could do the same thing? or maybe there's just a setting somewhere I've overlooked.Thanks for your help,
Oli
...bit of context We're running a Rails 7.1 app with Turbo. Below are our controller setups.