What is the proper way to use the Atlassian Connect History Module's pushState() method? (JIRA)

I am not getting the desired behavior from my code.

AP.require(["history"], function(history) {
    var diagramAnchorName = 'MyAnchor';
    history.pushState(diagramAnchorName);
    // Close viewer on back button
    history.popState(function(e) {
        if(viewer.isShowing()) {
            viewer.close();
        }
    });
});

When I put a breakpoint after history.pushState(), I can then execute history.getState() via console and get back the expected value ('MyAnchor'). However, the URL in the browser (Chrome) is never updated, and the back button goes back to the previous page, rather than executing my history.popState() callback.

Any advice would be very appreciated.

2 answers

History API will only change the URI on page modules. eg: generalPage, adminPage, etc. It will not work for webitems, webpanels, or jiraIssuePanels.

Are you trying to use it outside of a page?

I am trying to use it from an iframe with my editor in it. Do you know of any ways others have dealt with similar situations?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot