Patch #13900

Update URL when changing tab

Added by Jean-Baptiste Barth almost 5 years ago. Updated over 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Baptiste Barth% Done:

0%

Category:UI
Target version:2.4.0

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.

Associated revisions

Revision 11765
Added by Jean-Baptiste Barth almost 5 years ago

Update URL when changing tab (#13900).

History

#1 Updated by Jean-Baptiste Barth almost 5 years ago

  • Description updated (diff)

#2 Updated by Jean-Baptiste Barth almost 5 years ago

  • Status changed from New to Resolved
  • Target version set to 2.4.0

Done in r11765

#3 Updated by Mischa The Evil almost 5 years ago

Nice... Thanks.

#4 Updated by Jean-Philippe Lang almost 5 years ago

Excellent!

#5 Updated by Jean-Philippe Lang over 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF