Project

General

Profile

Actions

Patch #13900

closed

Update URL when changing tab

Added by Jean-Baptiste Barth almost 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Category:
UI
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Redmine tabs (in Settings or Administration for instance) are all loaded at once when the page is loaded. When changing tab, the URL is not updated, hence it breaks navigation in some minor ways, which I find annoying on a daily basis.. :
  • if the user reloads the page he's sent back to the default tab, not the one he was viewing
  • previous/next buttons behave counterintuitively : only the default tab remains in the history, and once you leave a tab, you never go back to it without having to re-click on the tab

The simplest solution to that is to use the History API introduced a couple years ago in most browsers, so that URL is updated whenever a click on a new tab occurs. Basically it boils down to this:

/* better handling of history in redmine tabs */
$(function() {
  $(".tabs a").on("click", function() {
    //only trigger history API if supported
    if ("replaceState" in window.history) {
      //replace current URL with the "href" attribute of the current link
      window.history.replaceState(null, document.title, this.href);
    }
  })
})

Any opinion on that is welcome. If none I'll add it in the next few days, I think I'll integrate it directly in the showTab() function.

Actions

Also available in: Atom PDF