mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixing Dialog Escape keypress behavior (#831)
* Replacing dialog keypress target Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding explanatory comments Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
8d1f0efe80
commit
e11cbc19fe
@ -1,4 +1,3 @@
|
||||
import { WorkspaceId, workspaceStore } from "./workspace-store";
|
||||
import path from "path";
|
||||
import { app, ipcRenderer, remote } from "electron";
|
||||
import { unlink } from "fs-extra";
|
||||
@ -13,7 +12,7 @@ import { saveToAppFiles } from "./utils/saveToAppFiles";
|
||||
import { KubeConfig } from "@kubernetes/client-node";
|
||||
import _ from "lodash";
|
||||
import move from "array-move";
|
||||
import { is } from "immer/dist/internal";
|
||||
import type { WorkspaceId } from "./workspace-store";
|
||||
|
||||
export interface ClusterIconUpload {
|
||||
clusterId: string;
|
||||
|
||||
@ -92,7 +92,8 @@ export class Dialog extends React.PureComponent<DialogProps, DialogState> {
|
||||
this.props.onOpen();
|
||||
if (!this.props.pinned) {
|
||||
if (this.elem) this.elem.addEventListener('click', this.onClickOutside);
|
||||
window.addEventListener('keydown', this.onEscapeKey);
|
||||
// Using document.body target to handle keydown event before Drawer does
|
||||
document.body.addEventListener('keydown', this.onEscapeKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +101,7 @@ export class Dialog extends React.PureComponent<DialogProps, DialogState> {
|
||||
this.props.onClose();
|
||||
if (!this.props.pinned) {
|
||||
if (this.elem) this.elem.removeEventListener('click', this.onClickOutside);
|
||||
window.removeEventListener('keydown', this.onEscapeKey);
|
||||
document.body.removeEventListener('keydown', this.onEscapeKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ export class Drawer extends React.Component<DrawerProps> {
|
||||
});
|
||||
|
||||
componentDidMount() {
|
||||
// Using window target for events to make sure they will be catched after other places (e.g. Dialog)
|
||||
window.addEventListener("mousedown", this.onMouseDown)
|
||||
window.addEventListener("click", this.onClickOutside)
|
||||
window.addEventListener("keydown", this.onEscapeKey)
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
div.logo-text {
|
||||
position: absolute;
|
||||
left: 42px;
|
||||
top: 11.5px;
|
||||
top: 11px;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user