Commit 465dba3a authored by Phil Hughes's avatar Phil Hughes

Fixed issue where file would sometimes not get scrolled to

parent 34c3f332
...@@ -619,6 +619,7 @@ export default { ...@@ -619,6 +619,7 @@ export default {
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
:can-current-user-fork="canCurrentUserFork" :can-current-user-fork="canCurrentUserFork"
:view-diffs-file-by-file="viewDiffsFileByFile" :view-diffs-file-by-file="viewDiffsFileByFile"
:active="active"
/> />
</dynamic-scroller-item> </dynamic-scroller-item>
</template> </template>
......
...@@ -68,6 +68,11 @@ export default { ...@@ -68,6 +68,11 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
active: {
type: Boolean,
required: false,
default: true,
},
preRender: { preRender: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -300,7 +305,7 @@ export default { ...@@ -300,7 +305,7 @@ export default {
<template> <template>
<div <div
:id="file.file_hash" :id="!preRender && active && file.file_hash"
:class="{ :class="{
'is-active': currentDiffFileId === file.file_hash, 'is-active': currentDiffFileId === file.file_hash,
'comments-disabled': Boolean(file.brokenSymlink), 'comments-disabled': Boolean(file.brokenSymlink),
...@@ -343,7 +348,7 @@ export default { ...@@ -343,7 +348,7 @@ export default {
</div> </div>
<template v-else> <template v-else>
<div <div
:id="`diff-content-${file.file_hash}`" :id="!preRender && active && `diff-content-${file.file_hash}`"
:class="hasBodyClasses.contentByHash" :class="hasBodyClasses.contentByHash"
data-testid="content-area" data-testid="content-area"
> >
......
...@@ -29,11 +29,7 @@ export default { ...@@ -29,11 +29,7 @@ export default {
this.nextItem = nextItem; this.nextItem = nextItem;
}); });
} else if (this.startedRender) { } else if (this.startedRender) {
this.nextItem = null; this.clearRendering();
if (this.maxLength === this.vscrollParent.itemsWithSize.length) {
this.$_itemsWithSizeWatcher();
}
} }
}); });
}, },
...@@ -41,6 +37,13 @@ export default { ...@@ -41,6 +37,13 @@ export default {
this.$_itemsWithSizeWatcher(); this.$_itemsWithSizeWatcher();
}, },
methods: { methods: {
clearRendering() {
this.nextItem = null;
if (this.maxLength === this.vscrollParent.itemsWithSize.length) {
this.$_itemsWithSizeWatcher();
}
},
findNextToRender() { findNextToRender() {
return this.vscrollParent.itemsWithSize.find(({ size }, index) => { return this.vscrollParent.itemsWithSize.find(({ size }, index) => {
const isNext = size === 0; const isNext = size === 0;
......
...@@ -26,8 +26,6 @@ export default { ...@@ -26,8 +26,6 @@ export default {
this.scrollToIndex(index); this.scrollToIndex(index);
await this.$nextTick(); await this.$nextTick();
handleLocationHash();
} }
}); });
} }
...@@ -41,6 +39,10 @@ export default { ...@@ -41,6 +39,10 @@ export default {
methods: { methods: {
scrollToIndex(index) { scrollToIndex(index) {
this.vscrollParent.scrollToItem(index); this.vscrollParent.scrollToItem(index);
setTimeout(() => {
handleLocationHash();
});
}, },
}, },
render(h) { render(h) {
......
...@@ -544,7 +544,7 @@ export const scrollToFile = ({ state, commit }, path) => { ...@@ -544,7 +544,7 @@ export const scrollToFile = ({ state, commit }, path) => {
eventHub.$emit('scrollToFileHash', fileHash); eventHub.$emit('scrollToFileHash', fileHash);
setTimeout(() => { setTimeout(() => {
document.location.hash = fileHash; window.history.replaceState(null, null, `#${fileHash}`);
}); });
} else { } else {
document.location.hash = fileHash; document.location.hash = fileHash;
......
...@@ -98,7 +98,7 @@ export const handleLocationHash = () => { ...@@ -98,7 +98,7 @@ export const handleLocationHash = () => {
let adjustment = 0; let adjustment = 0;
if (fixedNav) adjustment -= fixedNav.offsetHeight; if (fixedNav) adjustment -= fixedNav.offsetHeight;
if (target && target.scrollIntoView && !target.classList.contains('is-virtual-scrolling')) { if (target && target.scrollIntoView) {
target.scrollIntoView(true); target.scrollIntoView(true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment