showFlag actions don't work after navigation

I figure it’s probably expected behaviour, but I need to confirm. I’m popping up a flag using Forge bridge’s showFlag function. The flag includes a close action.

    const { close } = showFlag({
        id: 'my-flag',
        title: 'This is a flag',
        description: `Flags are nice`,
        type: 'success',
        appearance: 'success',
        actions: [{
            text: 'Close',
            onClick: () => {
                close().then(() => true);
            },
        }],
        isAutoDismiss: false,
    });

It works fine while I’m still viewing the Forge custom UI that created the flag, but if I navigate away, the close action simply doesn’t work.

I figure it’s because the JavaScript behind the flag went away when I navigated to another page. Is that correct? Is there a way that I can have the flag actions work even after the navigation event?

2 Likes

I’m now wondering if I can create a separate background module - a Dashboard background script? - to display the flag. I could then publish an event to that background module when it’s time to display the flag.

Would that make the flag continue to work while navigation is happening?

1 Like

I have the same problem, @david.pinn have you solved it yet? I would be very grateful for your help.