Fix requiring double keypress to create new rows

This commit is contained in:
Andrew Kingston 2024-03-20 13:46:52 +00:00
parent 3788d67e8d
commit f458ae20a9
1 changed files with 7 additions and 5 deletions

View File

@ -40,16 +40,18 @@
}
}
// Handle certain key presses regardless of selection state
if (e.key === "Enter" && (e.ctrlKey || e.metaKey) && $config.canAddRows) {
e.preventDefault()
dispatch("add-row-inline")
return
}
// If nothing selected avoid processing further key presses
if (!$focusedCellId) {
if (e.key === "Tab" || e.key?.startsWith("Arrow")) {
e.preventDefault()
focusFirstCell()
} else if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
if ($config.canAddRows) {
e.preventDefault()
dispatch("add-row-inline")
}
} else if (e.key === "Delete" || e.key === "Backspace") {
if (Object.keys($selectedRows).length && $config.canDeleteRows) {
dispatch("request-bulk-delete")