Fixes the diff changes buttons from toggling when scrolling

Closes #36698
This commit is contained in:
Phil Hughes 2017-08-29 13:34:12 +01:00
parent c274da069d
commit ab3c8302af
4 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,5 @@
export const isSticky = (el, scrollY, stickyTop) => {
const top = el.offsetTop - scrollY;
const top = Math.floor(el.offsetTop - scrollY);
if (top <= stickyTop) {
el.classList.add('is-stuck');

View File

@ -253,6 +253,7 @@ import bp from './breakpoints';
loadDiff(source) {
if (this.diffsLoaded) {
document.dispatchEvent(new CustomEvent('scroll'));
return;
}

View File

@ -0,0 +1,5 @@
---
title: Fixed diff changes bar buttons from showing/hiding whilst scrolling
merge_request:
author:
type: fixed

View File

@ -295,6 +295,17 @@ import 'vendor/jquery.scrollTo';
this.class.loadDiff('/foo/bar/merge_requests/1/diffs');
});
it('triggers scroll event when diff already loaded', function () {
spyOn(document, 'dispatchEvent');
this.class.diffsLoaded = true;
this.class.loadDiff('/foo/bar/merge_requests/1/diffs');
expect(
document.dispatchEvent,
).toHaveBeenCalledWith(new CustomEvent('scroll'));
});
describe('with inline diff', () => {
let noteId;
let noteLineNumId;