Commit 32969d49 authored by Phil Hughes's avatar Phil Hughes

Improves find function virtual scrolling disabling

Changes the key code to be `mod+f` to make sure `ctrl+f`
isn't captured on mac OS.
Adds a `mod+g` to make sure it works fully on firefox.
Adds a blur event so that we can be pretty certain that the
user is focused on the find box.
parent d0b20742
......@@ -506,9 +506,24 @@ export default {
);
}
Mousetrap.bind(['ctrl+f', 'command+f'], () => {
this.disableVirtualScroller = true;
});
if (window.gon?.features?.diffsVirtualScrolling) {
let keydownTime;
Mousetrap.bind(['mod+f', 'mod+g'], () => {
keydownTime = new Date().getTime();
});
window.addEventListener('blur', () => {
if (keydownTime) {
const delta = new Date().getTime() - keydownTime;
// To make sure the user is using the find function we need to wait for blur
// and max 1000ms to be sure it the search box is filtered
if (delta >= 0 && delta < 1000) {
this.disableVirtualScroller = true;
}
}
});
}
},
removeEventListeners() {
Mousetrap.unbind(keysFor(MR_PREVIOUS_FILE_IN_DIFF));
......
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