FIX: prevent event propagation when pressing escape key on lightbox (#22924)

When we use the escape key to exit lightbox for images within a chat channel, it also closes the chat drawer due to event bubbling (since both lightbox and chat use an event listener on the escape key).

This change prevents event bubbling when using the escape key within lightbox, which means that it will close the lightbox but won't close the chat drawer.
This commit is contained in:
David Battersby 2023-08-02 13:59:10 +08:00 committed by GitHub
parent db7581ce49
commit d8bf926d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -361,6 +361,7 @@ export default class DLightbox extends Component {
onKeydown(event) {
if (event.key === KEYBOARD_SHORTCUTS.CLOSE) {
event.preventDefault();
event.stopPropagation();
return this.close();
}
}