fix: restrict keyboard event handling to modal elements only (#6408)

* fix: restrict keyboard event handling to modal elements only

* chore: minor refactor

---------

Co-authored-by: Bijin A B <bijin@usebruno.com>
This commit is contained in:
Pragadesh-45
2025-12-19 19:01:08 +05:30
committed by GitHub
parent f47e9e9304
commit 41efa8505b

View File

@@ -82,6 +82,12 @@ const Modal = ({
const handleKeydown = (event) => {
const { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;
// Only handle events from elements inside this modal
if (keyCode !== ESC_KEY_CODE && (!modalRef.current || !modalRef.current.contains(event.target))) {
return;
}
switch (keyCode) {
case ESC_KEY_CODE: {
if (disableEscapeKey) return;