diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-09-26 14:58:14 +0200 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-10-04 17:27:56 +0200 |
commit | 9196a356ae675ab97e7ed49e48c1e59105ad2a81 (patch) | |
tree | daabd5521bf28be3b31a2514cfb2e875cd6190fd /app/assets | |
parent | e58c8413d47080498f4327cbcb6e08edae44aa9e (diff) | |
download | gitlab-ce-9196a356ae675ab97e7ed49e48c1e59105ad2a81.tar.gz |
Polished Back Button for files that are not in the tree anymore
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/repo/components/repo_sidebar.vue | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/repo/components/repo_sidebar.vue b/app/assets/javascripts/repo/components/repo_sidebar.vue index 535206bafe3..702056a7e3a 100644 --- a/app/assets/javascripts/repo/components/repo_sidebar.vue +++ b/app/assets/javascripts/repo/components/repo_sidebar.vue @@ -26,7 +26,11 @@ export default { methods: { addPopEventListener() { window.addEventListener('popstate', (event) => { - const selectedFile = this.files.find(file => location.href.indexOf(file.url) > -1); + let selectedFile = this.files.find(file => {return location.pathname.indexOf(file.url) > -1}); + if (!selectedFile) { + // Maybe it is not in the current tree but in the opened tabs + selectedFile = Store.openedFiles.find(file => {return location.pathname.indexOf(file.url) > -1}); + } if (selectedFile) { if (selectedFile.url !== this.activeFile.url) { this.fileClicked(selectedFile); @@ -46,6 +50,11 @@ export default { } } } + } else { + // Not opened at all lets open new tab + this.fileClicked({ + url: location.href, + }); } }); }, |