Shopify / shopify-app-js

MIT License
219 stars 88 forks source link

[shopify-app-remix] AppProvider breaks Polaris Button component external links #1153

Open joseph-carino opened 6 days ago

joseph-carino commented 6 days ago

Issue summary

Before opening this issue, I have:

When an embedded app using the provided <AppProvider> component renders a Polaris <Button> component with the url and external properties set, the rendered button does not open in a new tab/window.

<AppProvider> overrides the LinkComponent, which is fine for links, but the Polaris Button component actually renders an UnstyledLink component when the url property is provided. The UnstyledLink normally sets the target on the rendered <a> when external is provided, but the intercepting RemixPolarisLink does not.

Expected behavior

For the following Polaris react component:

image

The rendered html should include target="_blank":

image

Actual behavior

For the same Polaris react component as above, the rendered html does not include target="_blank":

image

Steps to reproduce the problem

  1. Create a new remix app using the shopify-app-remix-template template
  2. Replace the <script> tag in app/routes/app.tsx with <AppProvider>, as instructed in the migration docs
  3. Add a Polaris button component to the route, providing both the url and external properties
matteodepalo commented 5 days ago

Hi @joseph-carino thank you for reporting this issue, we'll take a look 👍 Is using the LinkComponent a valid workaround for you or do you need to use Button?