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?

3 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.

1 Like

We also run into this problem – specifically on Jira’s issue-view where we render a flag coming from our issue-view-background-script. As soon as the user navigates away from the issue, all actions of our flag fail with error-message “Uncaught Error: Can not send postrobot_method. Target window is closed
With this limitation we’ll just don’t use flag-actions at all.

I wonder if this limitation is known to Atlassian, and if they have any guidance for us. Should we just not use flag-actions on those situations? Tagging an Atlassian-employee active in this topic: @mpaisley

1 Like