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

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-10-29 16:09:05 -04:00
parent d975a19e7b
commit 6873100baa

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;