Update grid keyboard handling to bring invalid origin consideration to be highest precedence

This commit is contained in:
Andrew Kingston 2023-04-26 16:04:14 +01:00
parent defcc7a273
commit 44ef27299a
1 changed files with 14 additions and 5 deletions

View File

@ -15,8 +15,22 @@
selectedRows,
} = getContext("grid")
const ignoredOriginSelectors = [
".spectrum-Modal",
"#builder-side-panel-container",
]
// Global key listener which intercepts all key events
const handleKeyDown = e => {
// Avoid processing events sourced from certain origins
if (e.target?.closest) {
for (let selector of ignoredOriginSelectors) {
if (e.target.closest(selector)) {
return
}
}
}
// If nothing selected avoid processing further key presses
if (!$focusedCellId) {
if (e.key === "Tab" || e.key?.startsWith("Arrow")) {
@ -60,11 +74,6 @@
return
}
}
// Avoid processing events sourced from modals
if (e.target?.closest?.(".spectrum-Modal")) {
return
}
e.preventDefault()
// Handle the key ourselves