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:
parent
205cce43c7
commit
79c4132df9
@ -75,15 +75,26 @@ export class Drawer extends React.Component<DrawerProps> {
|
|||||||
window.addEventListener("mousedown", this.onMouseDown);
|
window.addEventListener("mousedown", this.onMouseDown);
|
||||||
window.addEventListener("click", this.onClickOutside);
|
window.addEventListener("click", this.onClickOutside);
|
||||||
window.addEventListener("keydown", this.onEscapeKey);
|
window.addEventListener("keydown", this.onEscapeKey);
|
||||||
|
window.addEventListener("click", this.fixUpTripleClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.stopListenLocation();
|
this.stopListenLocation();
|
||||||
window.removeEventListener("mousedown", this.onMouseDown);
|
window.removeEventListener("mousedown", this.onMouseDown);
|
||||||
window.removeEventListener("click", this.onClickOutside);
|
window.removeEventListener("click", this.onClickOutside);
|
||||||
|
window.removeEventListener("click", this.fixUpTripleClick);
|
||||||
window.removeEventListener("keydown", this.onEscapeKey);
|
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 = () => {
|
saveScrollPos = () => {
|
||||||
if (!this.scrollElem) return;
|
if (!this.scrollElem) return;
|
||||||
const key = history.location.key;
|
const key = history.location.key;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user