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