diff --git a/packages/frontend-core/src/components/grid/layout/NewRow.svelte b/packages/frontend-core/src/components/grid/layout/NewRow.svelte index da5e557a58..0729e032ec 100644 --- a/packages/frontend-core/src/components/grid/layout/NewRow.svelte +++ b/packages/frontend-core/src/components/grid/layout/NewRow.svelte @@ -23,16 +23,25 @@ rowHeight, hasNextPage, maxScrollTop, + rowVerticalInversionIndex, + columnHorizontalInversionIndex, } = getContext("grid") let isAdding = false let newRow = {} let offset = 0 - $: minimumDesiredRenderHeight = $rowHeight + 96 $: firstColumn = $stickyColumn || $renderedColumns[0] $: width = GutterWidth + ($stickyColumn?.width || 0) $: $tableId, (isAdding = false) + $: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows) + + const shouldInvertY = (offset, inversionIndex, rows) => { + if (offset === 0) { + return false + } + return rows.length >= inversionIndex + } const addRow = async () => { // Blur the active cell and tick to let final value updates propagate @@ -82,13 +91,16 @@ $renderedRows.length * $rowHeight - ($maxScrollTop % $rowHeight) - 1 } - document.addEventListener("keydown", handleKeyPress) + // Update state and select initial cell newRow = {} isAdding = true $hoveredRowId = NewRowID if (firstColumn) { $focusedCellId = `${NewRowID}-${firstColumn.name}` } + + // Attach key listener + document.addEventListener("keydown", handleKeyPress) } const updateValue = (rowId, columnName, val) => { @@ -127,24 +139,16 @@
0} - style="--offset:{offset}px" + style="--offset:{offset}px; --sticky-width:{width}px;" > -
+
-
+
{#if $stickyColumn} - {@const cellId = `new-${$stickyColumn.name}`} + {@const cellId = `${NewRowID}-${$stickyColumn.name}`} {/if}
-
+
-
- {#each $renderedColumns as column} +
+ {#each $renderedColumns as column, columnIdx} {@const cellId = `new-${column.name}`} {#key cellId} = $columnHorizontalInversionIndex} + {invertY} /> {/key} {/each} @@ -217,6 +224,7 @@ } .underlay.sticky { z-index: 2; + width: var(--sticky-width); } /* Floating buttons which sit on top of the underlay but below the sticky column */ @@ -237,6 +245,7 @@ z-index: 4; position: relative; align-self: flex-start; + flex: 0 0 var(--sticky-width); } .sticky-column :global(.cell:not(:last-child)) { border-right: none;