Commit bfd4ef43 authored by Jan Beckmann's avatar Jan Beckmann Committed by Kushal Pandya

Delay window.scrollBy in handleLocationHash to fix FF bug

Closes #19132
parent 23f058eb
...@@ -135,7 +135,9 @@ export const handleLocationHash = () => { ...@@ -135,7 +135,9 @@ export const handleLocationHash = () => {
adjustment -= topPadding; adjustment -= topPadding;
} }
setTimeout(() => {
window.scrollBy(0, adjustment); 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