History API is not usable in Confluence add-ons

XMLWordPrintable

    • Severity 2 - Major

      We developed several add-ons that make use of the History API with the library History.js and its pushState method. In Confluence >= 5.6 we observed some weird behaviour as soon as we called History.pushState: first, our code is run, but then the page suddenly reloads.

      I spent quite some time tracking this issue down and found the responsible JS code in the module com.atlassian.confluence.plugins.quickedit:editor-view-resources. The module globally binds the "popstate" event:

      $(window).bind("popstate", handleEvent(handleNavigationEvent, popStateFilters));
      

      Later on, the method actuallyNavigatePlease finally triggers a call to window.location.reload(). It seems that this call is really made globally any time the browser history is changed (when onpopstate is triggered). History.js triggeres the popstate event upon pushState, so the library is actually unusable in Confluence.

      EDIT:
      This issue actually not only makes History.js unusable but also the whole native browser History API. If you call pushState on the browser-native history object and click back in the browser afterwards, the popstate event will be triggered and Confluence will reload the page! This cannot be desired behaviour!

            Assignee:
            Unassigned
            Reporter:
            Felix Grund (Scandio)
            Votes:
            10 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: