Commit ec72fdc2 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '19132-comment-anchor-twice-firefox' into 'master'

Resolve "Clicking on comment anchor link twice is broken in Firefox"

Closes #19132

See merge request gitlab-org/gitlab!21699
parents 23f058eb bfd4ef43
...@@ -135,7 +135,9 @@ export const handleLocationHash = () => { ...@@ -135,7 +135,9 @@ export const handleLocationHash = () => {
adjustment -= topPadding; adjustment -= topPadding;
} }
window.scrollBy(0, adjustment); setTimeout(() => {
window.scrollBy(0, adjustment);
});
}; };
// Check if element scrolled into viewport from above or below // Check if element scrolled into viewport from above or below
......
---
title: Fix bug when clicking on same note twice in Firefox
merge_request: 21699
author: Jan Beckmann
type: fixed
...@@ -88,10 +88,12 @@ describe('common_utils', () => { ...@@ -88,10 +88,12 @@ describe('common_utils', () => {
describe('handleLocationHash', () => { describe('handleLocationHash', () => {
beforeEach(() => { beforeEach(() => {
spyOn(window.document, 'getElementById').and.callThrough(); spyOn(window.document, 'getElementById').and.callThrough();
jasmine.clock().install();
}); });
afterEach(() => { afterEach(() => {
window.history.pushState({}, null, ''); window.history.pushState({}, null, '');
jasmine.clock().uninstall();
}); });
function expectGetElementIdToHaveBeenCalledWith(elementId) { function expectGetElementIdToHaveBeenCalledWith(elementId) {
...@@ -171,6 +173,7 @@ describe('common_utils', () => { ...@@ -171,6 +173,7 @@ describe('common_utils', () => {
window.history.pushState({}, null, '#test'); window.history.pushState({}, null, '#test');
commonUtils.handleLocationHash(); commonUtils.handleLocationHash();
jasmine.clock().tick(1);
expectGetElementIdToHaveBeenCalledWith('test'); expectGetElementIdToHaveBeenCalledWith('test');
expectGetElementIdToHaveBeenCalledWith('user-content-test'); expectGetElementIdToHaveBeenCalledWith('user-content-test');
......
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