Commit 20276aaa authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/330126/scrollToDiffNote' into 'master'

Fixed scrolling to diff notes not working with virtual scroller

See merge request gitlab-org/gitlab!65060
parents df3a9aa8 76bb4c6e
......@@ -475,7 +475,11 @@ export default {
},
setDiscussions() {
requestIdleCallback(
() => this.assignDiscussionsToDiff().then(this.$nextTick).then(this.startTaskList),
() =>
this.assignDiscussionsToDiff()
.then(this.$nextTick)
.then(this.startTaskList)
.then(this.scrollVirtualScrollerToDiffNote),
{ timeout: 1000 },
);
},
......@@ -539,6 +543,22 @@ export default {
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,
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