Shopify / shopify-app-bridge

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

Issue with Toast `onAction` Not Triggering in Shopify App Bridge #261

Open vildanbina opened 6 months ago

vildanbina commented 6 months ago

Describe the bug

I've encountered an issue with the Toast component in Shopify App Bridge: the onAction event does not trigger after clicking the action button. This occurs in the following scenario:

To Reproduce

Steps to reproduce the behavior:

  1. Declare the Toast instance:
    
    import { Toast } from '@shopify/app-bridge/actions';

const app = createApp({ apiKey: 'API_KEY', host: 'HOST', forceRedirect: true, });

const toastInstance = Toast.create(app, { message: 'User has been successfully deleted!', duration: 3000, action: { content: 'Undo', onAction: () => { console.log(1); }, }, })


2. Dispatch to show the toast:
```js
toastInstance.dispatch(Toast.Action.SHOW);

The toast displays correctly, and the 'Undo' link appears. However, clicking on 'Undo' results in no action.

Expected behaviour

Clicking on 'Undo' should trigger the onAction method, which in my case would log to the console.

Contextual information

Packages and versions

Platform