Fixed IDE file row jumping into view on hover

Closes #50751
This commit is contained in:
Phil Hughes 2018-08-28 11:37:43 +01:00
parent 9248240cf4
commit 27bce7ad2c
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
3 changed files with 33 additions and 5 deletions

View File

@ -95,16 +95,18 @@ export default {
return this.file.changed || this.file.tempFile || this.file.staged;
},
},
watch: {
'file.active': function fileActiveWatch(active) {
if (this.file.type === 'blob' && active) {
this.scrollIntoView();
}
},
},
mounted() {
if (this.hasPathAtCurrentRoute()) {
this.scrollIntoView(true);
}
},
updated() {
if (this.file.type === 'blob' && this.file.active) {
this.scrollIntoView();
}
},
methods: {
...mapActions(['toggleTreeOpen']),
clickFile() {

View File

@ -0,0 +1,5 @@
---
title: Fixed IDE file row scrolling into view when hovering
merge_request:
author:
type: fixed

View File

@ -121,4 +121,25 @@ describe('RepoFile', () => {
).toContain('Locked by testuser');
});
});
it('calls scrollIntoView if made active', done => {
createComponent({
file: {
...file(),
type: 'blob',
active: false,
},
level: 0,
});
spyOn(vm, 'scrollIntoView');
vm.file.active = true;
vm.$nextTick(() => {
expect(vm.scrollIntoView).toHaveBeenCalled();
done();
});
});
});