Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
85 stars 9 forks source link

contextualSaveBar when open doesn't prevent redirection when forceRedirect is set to true on provider gotten from @shopify/app-bridge-react #167 #169

Open 0xspryon opened 1 year ago

0xspryon commented 1 year ago

Describe the bug

When forceRedirect: true is configured on Provider gotten from import { Provider } from "@shopify/app-bridge-react", ContextualSaveBar ( gotten from import { ContextualSaveBar } from "@shopify/app-bridge/actions") when open no longer prevents redirection during a redirection event.

To Reproduce

  1. in _app.tsx file.
import { Provider } from "@shopify/app-bridge-react"

class MyApp extends App {

render() {
  return (
    <Provider
            config={{
              apiKey,
              host,
              forceRedirect: true,
            }}
          >
             ...
     </Provider>
  1. in any of our pages
import { ContextualSaveBar } from "@shopify/app-bridge/actions"
import { useEffect } from "react"

const ComponentName = () => {
  const contextualSaveBar = ContextualSaveBar.create(app, {
     saveAction: {
        disabled: false,
        loading: false,
      },
      discardAction: {
        disabled: false,
        loading: false,
        discardConfirmationModal: false,
      },
      leaveConfirmationDisable: false,
    })

  useEffect(() => contextualSaveBar.dispatch(ContextualSaveBar.Action.SHOW), [])
}
  1. When on this page and the contextualSaveBar is shown, press the browser back button.
  2. DismissConfirm modal shows up but we can see in the background that redirection occurred.

Expected behavior

Even in the above configuration, the dismissConfirm modal but without the actual redirection occurring.

Contextual information

Packages and versions

"@shopify/app-bridge-react": "3.2.2"
"@shopify/app-bridge-utils": "3.2.2"

Platform