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

Adding explanatory comments

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-09-09 16:17:47 +03:00
parent 4118d9d1e5
commit edfbfd2cfb
2 changed files with 2 additions and 0 deletions

View File

@ -92,6 +92,7 @@ export class Dialog extends React.PureComponent<DialogProps, DialogState> {
this.props.onOpen(); this.props.onOpen();
if (!this.props.pinned) { if (!this.props.pinned) {
if (this.elem) this.elem.addEventListener('click', this.onClickOutside); if (this.elem) this.elem.addEventListener('click', this.onClickOutside);
// Using document.body target to handle keydown event before Drawer does
document.body.addEventListener('keydown', this.onEscapeKey); document.body.addEventListener('keydown', this.onEscapeKey);
} }
} }

View File

@ -40,6 +40,7 @@ export class Drawer extends React.Component<DrawerProps> {
}); });
componentDidMount() { 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("mousedown", this.onMouseDown)
window.addEventListener("click", this.onClickOutside) window.addEventListener("click", this.onClickOutside)
window.addEventListener("keydown", this.onEscapeKey) window.addEventListener("keydown", this.onEscapeKey)