Commit 76bb4c6e authored by Phil Hughes's avatar Phil Hughes

Fixed scrolling to diff notes not working with virtual scroller

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/330126
parent be408943
...@@ -474,7 +474,11 @@ export default { ...@@ -474,7 +474,11 @@ export default {
}, },
setDiscussions() { setDiscussions() {
requestIdleCallback( requestIdleCallback(
() => this.assignDiscussionsToDiff().then(this.$nextTick).then(this.startTaskList), () =>
this.assignDiscussionsToDiff()
.then(this.$nextTick)
.then(this.startTaskList)
.then(this.scrollVirtualScrollerToDiffNote),
{ timeout: 1000 }, { timeout: 1000 },
); );
}, },
...@@ -538,6 +542,22 @@ export default { ...@@ -538,6 +542,22 @@ export default {
this.virtualScrollCurrentIndex = -1; this.virtualScrollCurrentIndex = -1;
}, },
scrollVirtualScrollerToDiffNote() {
if (!window.gon?.features?.diffsVirtualScrolling) return;
const id = window?.location?.hash;
if (id.startsWith('#note_')) {
const noteId = id.replace('#note_', '');
const discussion = this.$store.state.notes.discussions.find((d) =>
d.notes.find((n) => n.id === noteId),
);
if (discussion) {
this.scrollVirtualScrollerToFileHash(discussion.diff_file.file_hash);
}
}
},
}, },
minTreeWidth: MIN_TREE_WIDTH, minTreeWidth: MIN_TREE_WIDTH,
maxTreeWidth: MAX_TREE_WIDTH, maxTreeWidth: MAX_TREE_WIDTH,
......
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