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

Internal Polaris links are always opening new tab with wrong URL #1916

Open
key88sf opened this issue Oct 16, 2024 · 2 comments
Open

Internal Polaris links are always opening new tab with wrong URL #1916

key88sf opened this issue Oct 16, 2024 · 2 comments
Assignees

Comments

@key88sf
Copy link

key88sf commented Oct 16, 2024

Issue summary

Before opening this issue, I have:

  • [x ] Upgraded to the latest version of the package
    • shopify_app version: 22.4.0
    • Ruby version: 3.3.1
    • Operating system: Mac OS X Sonoma 14.6.1
  • [x ] Set log_level: :debug in my configuration, if applicable
  • [x ] Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • [x ] Looked for similar issues in this repository
  • [x ] Checked that this isn't an issue with a Shopify API

Using Shopify App with app-bridge v.4, any relative links from Polaris components (Link, Button, etc) are opening in a new tab, and not using the proper shopify admin store URL.

Using the boilerplate Ruby shopify app from the app template (https://github.com/Shopify/shopify-app-template-ruby), I create a Polaris link like this: <Link url="/pagename">Click Me</Link> and then click the link.

Expected behavior

Clicking the polaris Link element above should change browser URL to: https://admin.shopify.com/store/mystore/apps/my-app/pagename (not opening new tab)

Actual behavior

Clicking the link opens a new tab, with URL: https://<cloudflare-tunnel-host>/pagename.

This URL is not using the shopify store URL at all -- it is just using the underlying Rails host name. It seems to be totally bypassing the React router.

This worked fine with App Bridge V3 --- since in the PolarisProvider.jsx class, it was using the AppBridge navigate() method. Now with AppBridge v4, that same class is now calling window.open(url) which ends up opening a new tab.

Steps to reproduce the problem

  1. Create a new Shopify App (ruby) using the Shopify App Template for Ruby
  2. Add a Polaris Link element to an internal app page (e.g. /pagename)
  3. Click the link in the app UI
@lizkenyon
Copy link
Contributor

Thanks for flagging! The team will look into this.

@key88sf
Copy link
Author

key88sf commented Oct 16, 2024

@lizkenyon @andy-liuu I also opened the issue in the Shopify Frontend Template React repo since that is where the PolarisProvider resides. I also believe I found a proper fix:

Shopify/shopify-frontend-template-react#306

Would be great if you can confirm that, thanks!

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

3 participants