From 89ccf48b027d22896857aac4adb627a71957a9a8 Mon Sep 17 00:00:00 2001
From: Simon Knox <simon@gitlab.com>
Date: Thu, 29 Jun 2023 07:23:15 +0000
Subject: [PATCH] Revert "Merge branch 'fix-scroll-to-note' into 'master'"

This reverts merge request !123957
---
 app/assets/javascripts/diffs/constants.js     |  1 -
 .../notes/components/noteable_note.vue        | 19 +++++++------------
 .../notes/components/notes_app.vue            |  1 -
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/app/assets/javascripts/diffs/constants.js b/app/assets/javascripts/diffs/constants.js
index c113bb24fb5f74..575cd05ceb898f 100644
--- a/app/assets/javascripts/diffs/constants.js
+++ b/app/assets/javascripts/diffs/constants.js
@@ -117,4 +117,3 @@ export const TRACKING_MULTIPLE_FILES_MODE = 'i_code_review_diff_multiple_files';
 
 // UI
 export const ZERO_CHANGES_ALT_DISPLAY = '-';
-export const STICKY_FILE_HEADER_HEIGHT = 40;
diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue
index babe005a1f3886..50262e81f1c3f6 100644
--- a/app/assets/javascripts/notes/components/noteable_note.vue
+++ b/app/assets/javascripts/notes/components/noteable_note.vue
@@ -5,7 +5,7 @@ import { escape, isEmpty } from 'lodash';
 import { mapGetters, mapActions } from 'vuex';
 import SafeHtml from '~/vue_shared/directives/safe_html';
 import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal';
-import { INLINE_DIFF_LINES_KEY, STICKY_FILE_HEADER_HEIGHT } from '~/diffs/constants';
+import { INLINE_DIFF_LINES_KEY } from '~/diffs/constants';
 import { createAlert } from '~/alert';
 import { HTTP_STATUS_GONE } from '~/lib/utils/http_status';
 import { ignoreWhilePending } from '~/lib/utils/ignore_while_pending';
@@ -14,7 +14,6 @@ import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item
 import { __, s__, sprintf } from '~/locale';
 import { renderGFM } from '~/behaviors/markdown/render_gfm';
 import { containsSensitiveToken, confirmSensitiveAction } from '~/lib/utils/secret_detection';
-import { scrollToElement } from '~/lib/utils/common_utils';
 import eventHub from '../event_hub';
 import noteable from '../mixins/noteable';
 import resolvable from '../mixins/resolvable';
@@ -235,13 +234,12 @@ export default {
         this.scrollToNoteIfNeeded($(this.$el));
       }
     });
+  },
 
-    eventHub.$on('scrollToNote', () => {
-      if (this.isTarget && this.shouldScrollToNote) {
-        const offset = this.line ? STICKY_FILE_HEADER_HEIGHT * -1 : 0;
-        setTimeout(() => scrollToElement(this.$el, { offset, behavior: 'instant' }), 1500);
-      }
-    });
+  mounted() {
+    if (this.isTarget && this.shouldScrollToNote) {
+      this.scrollToNoteIfNeeded($(this.$el));
+    }
   },
 
   methods: {
@@ -422,10 +420,7 @@ export default {
 <template>
   <timeline-entry-item
     :id="noteAnchorId"
-    :class="{
-      ...classNameBindings,
-      'internal-note': note.internal,
-    }"
+    :class="{ ...classNameBindings, 'internal-note': note.internal }"
     :data-award-url="note.toggle_award_path"
     :data-note-id="note.id"
     class="note note-wrapper note-comment"
diff --git a/app/assets/javascripts/notes/components/notes_app.vue b/app/assets/javascripts/notes/components/notes_app.vue
index dcafdbffec490f..06c925002b63c5 100644
--- a/app/assets/javascripts/notes/components/notes_app.vue
+++ b/app/assets/javascripts/notes/components/notes_app.vue
@@ -165,7 +165,6 @@ export default {
   updated() {
     this.$nextTick(() => {
       highlightCurrentUser(this.$el.querySelectorAll('.gfm-project_member'));
-      eventHub.$emit('scrollToNote');
     });
   },
   beforeDestroy() {
-- 
GitLab