Follow-up from "Fix creating permalink with shortcut key "y""

The following discussion from !150836 (merged) should be addressed:

  • @kpalchyk started a discussion: (+4 comments)

    And then I found another issue, which I haven't verified before. When the permalink button is hit twice — the back button navigation now throws a router error:

    issue_-_permalinked_twice

    With the following console error:

    image

    I tested both on this branch and on master. Both issues are reproducible in both branches. So it's not related to current MR directly.

  • @markrian (!150836 (comment 1929623207)):

    The first one happens even if you don't click the permalink button. Just load the file tree in a fresh tab, click a file, click reload, and then hit back - the URL changes, but not the page content. I imagine this is because of how the Vue content replaces the DOM of the initial HAML view. That is, it's not a real navigation we're going back to, and we've not given the browser enough information about how to recover the original state. It's just lost.

    The second one is interesting. I can recreate the error without a second click on the permalink:

    1. Navigate to file list
    2. Click a file
    3. Click the permalink button
    4. Click back
    5. Click forward
    6. Error

    The error is thrown from ~/repository/router.js#L74.

    Here's a "good" to object followed by the one that causes the exception in this back/forward case: back_forward

    And here it is in the double-permalink-click-then-back case: double_permalink

    I would guess the fix would be to use router.push() rather than updateHistory in the permalink/shortcut callback, but that gets a bit tricky to wire up.

NOTE: moveToFilePermalink() utility function that calls updateHistory is used both for a HAML view and Vue.js component.