1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Reduce selection on triple click in Drawers (#4201)

This commit is contained in:
Sebastian Malton 2021-11-03 10:10:07 -04:00 committed by GitHub
parent 205cce43c7
commit 79c4132df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,15 +75,26 @@ export class Drawer extends React.Component<DrawerProps> {
window.addEventListener("mousedown", this.onMouseDown);
window.addEventListener("click", this.onClickOutside);
window.addEventListener("keydown", this.onEscapeKey);
window.addEventListener("click", this.fixUpTripleClick);
}
componentWillUnmount() {
this.stopListenLocation();
window.removeEventListener("mousedown", this.onMouseDown);
window.removeEventListener("click", this.onClickOutside);
window.removeEventListener("click", this.fixUpTripleClick);
window.removeEventListener("keydown", this.onEscapeKey);
}
fixUpTripleClick = (ev: MouseEvent) => {
// detail: A count of consecutive clicks that happened in a short amount of time
if (ev.detail === 3) {
const selection = window.getSelection();
selection.selectAllChildren(selection.anchorNode?.parentNode);
}
};
saveScrollPos = () => {
if (!this.scrollElem) return;
const key = history.location.key;