diff --git a/web_src/js/components/DiffFileTree.vue b/web_src/js/components/DiffFileTree.vue
index 7ed1ef151e..e978d7bce6 100644
--- a/web_src/js/components/DiffFileTree.vue
+++ b/web_src/js/components/DiffFileTree.vue
@@ -5,7 +5,7 @@
>
{{ tooManyFilesMessage }}{{ showMoreMessage }}
@@ -25,7 +25,10 @@ export default {
data: () => {
const fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) === 'true';
pageData.diffFileInfo.fileTreeIsVisible = fileTreeIsVisible;
- return pageData.diffFileInfo;
+ return {
+ ...pageData.diffFileInfo,
+ selectedFile: ''
+ };
},
computed: {
fileTree() {
@@ -98,9 +101,16 @@ export default {
pageData.diffFileInfo.files = this.files;
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
+
+ this.hashChangeListener = () => {
+ this.selectedFile = window.location.hash;
+ };
+ this.hashListener = window.addEventListener('hashchange', this.hashChangeListener);
+ this.selectedFile = window.location.hash;
},
unmounted() {
document.querySelector('.diff-toggle-file-tree-button').removeEventListener('click', this.toggleVisibility);
+ window.removeEventListener('hashchange', this.hashChangeListener);
},
methods: {
toggleVisibility() {
diff --git a/web_src/js/components/DiffFileTreeItem.vue b/web_src/js/components/DiffFileTreeItem.vue
index f0a3d909b9..ea5d48840c 100644
--- a/web_src/js/components/DiffFileTreeItem.vue
+++ b/web_src/js/components/DiffFileTreeItem.vue
@@ -1,7 +1,7 @@
@@ -54,6 +54,11 @@ export default {
type: Boolean,
required: false,
default: true
+ },
+ selectedFile: {
+ type: String,
+ default: '',
+ required: true
}
},
data: () => ({
@@ -76,6 +81,9 @@ export default {
};
return diffTypes[pType];
},
+ genCompleteFileHash(hash) {
+ return `#diff-${hash}`;
+ }
},
};
@@ -115,12 +123,18 @@ span.svg-icon.octicon-diff-renamed {
padding-left: 18px !important;
}
-.item.filewrapper:hover {
+.item.filewrapper:hover, div.directory:hover {
color: var(--color-text);
background: var(--color-hover);
border-radius: 4px;
}
+.item.filewrapper.selected {
+ color: var(--color-text);
+ background: var(--color-active);
+ border-radius: 4px;
+}
+
div.directory {
display: grid;
grid-template-columns: 18px 20px auto;
@@ -128,12 +142,6 @@ div.directory {
cursor: pointer;
}
-div.directory:hover {
- color: var(--color-text);
- background: var(--color-hover);
- border-radius: 4px;
-}
-
div.list {
padding-bottom: 0 !important;
padding-top: inherit !important;