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:
Alex Andreev authored and GitHub committed 2020-09-10 09:31:23 +03:00
1 parent 8d1f0efe80
commit e11cbc19fe
4 files changed
+6 -5

No files matched your search

+3 -2
View File
@@ -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)
+1 -1
View File
@@ -40,7 +40,7 @@
div.logo-text {
position: absolute;
left: 42px;
top: 11.5px;
top: 11px;
}
.logo-icon {