diff --git a/packages/frontend-core/src/components/grid/layout/NewRow.svelte b/packages/frontend-core/src/components/grid/layout/NewRow.svelte index 48c5dcec69..607dc9e1f0 100644 --- a/packages/frontend-core/src/components/grid/layout/NewRow.svelte +++ b/packages/frontend-core/src/components/grid/layout/NewRow.svelte @@ -27,13 +27,14 @@ columnHorizontalInversionIndex, } = getContext("grid") + let visible = false let isAdding = false let newRow = {} let offset = 0 $: firstColumn = $stickyColumn || $renderedColumns[0] $: width = GutterWidth + ($stickyColumn?.width || 0) - $: $tableId, (isAdding = false) + $: $tableId, (visible = false) $: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows) const shouldInvertY = (offset, inversionIndex, rows) => { @@ -45,7 +46,8 @@ const addRow = async () => { // Blur the active cell and tick to let final value updates propagate - $focusedCellAPI?.blur() + isAdding = true + $focusedCellId = null await tick() // Create row @@ -60,17 +62,19 @@ $focusedCellId = `${savedRow._id}-${firstColumn.name}` } } + isAdding = false } const clear = () => { isAdding = false + visible = false $focusedCellId = null $hoveredRowId = null document.removeEventListener("keydown", handleKeyPress) } const startAdding = async () => { - if (isAdding) { + if (visible) { return } @@ -95,7 +99,7 @@ // Update state and select initial cell newRow = {} - isAdding = true + visible = true $hoveredRowId = NewRowID if (firstColumn) { $focusedCellId = `${NewRowID}-${firstColumn.name}` @@ -115,7 +119,7 @@ } const handleKeyPress = e => { - if (!isAdding) { + if (!visible) { return } if (e.key === "Escape") { @@ -137,7 +141,7 @@ -{#if isAdding} +{#if visible}