diff --git a/packages/frontend-core/src/components/sheet/cells/DataCell.svelte b/packages/frontend-core/src/components/sheet/cells/DataCell.svelte index a2eafdac21..edf604295c 100644 --- a/packages/frontend-core/src/components/sheet/cells/DataCell.svelte +++ b/packages/frontend-core/src/components/sheet/cells/DataCell.svelte @@ -1,5 +1,5 @@ - selectedCellId.set(cellId)} - on:contextmenu={e => menu.actions.open(cellId, e)} - width={column.width} -> - {#if !selected && showPlaceholder && (row[column.name] == null || row[column.name] === "")} -
- {column.name} -
- {:else} +{#key error} + selectedCellId.set(cellId)} + on:contextmenu={e => menu.actions.open(cellId, e)} + width={column.width} + > - {/if} - +
+{/key} diff --git a/packages/frontend-core/src/components/sheet/layout/SheetScrollWrapper.svelte b/packages/frontend-core/src/components/sheet/layout/SheetScrollWrapper.svelte index 31953d1d46..e7b61a37db 100644 --- a/packages/frontend-core/src/components/sheet/layout/SheetScrollWrapper.svelte +++ b/packages/frontend-core/src/components/sheet/layout/SheetScrollWrapper.svelte @@ -18,13 +18,20 @@ export let scrollVertically = true export let scrollHorizontally = true export let wheelInteractive = true + export let foo = false $: hiddenWidths = calculateHiddenWidths($renderedColumns) - $: style = generateStyle($scroll, $rowHeight, hiddenWidths) + $: style = generateStyle($scroll, $rowHeight, hiddenWidths, foo) - const generateStyle = (scroll, rowHeight, hiddenWidths) => { - const offsetX = scrollHorizontally ? -1 * scroll.left + hiddenWidths : 0 - const offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0 + const generateStyle = (scroll, rowHeight, hiddenWidths, foo) => { + let offsetX, offsetY + if (!foo) { + offsetX = scrollHorizontally ? -1 * scroll.left + hiddenWidths : 0 + offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0 + } else { + offsetX = scrollHorizontally ? -1 * scroll.left : 0 + offsetY = scrollVertically ? -1 * scroll.top : 0 + } return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);` } @@ -63,8 +70,8 @@ // Update state scroll.set({ - left: newScrollLeft, - top: newScrollTop, + left: scrollHorizontally ? newScrollLeft : left, + top: scrollVertically ? newScrollTop : top, }) // Hover row under cursor diff --git a/packages/frontend-core/src/components/sheet/layout/StickyColumn.svelte b/packages/frontend-core/src/components/sheet/layout/StickyColumn.svelte index 7239413855..ef6b509951 100644 --- a/packages/frontend-core/src/components/sheet/layout/StickyColumn.svelte +++ b/packages/frontend-core/src/components/sheet/layout/StickyColumn.svelte @@ -160,16 +160,14 @@ .sticky-column { display: flex; flex-direction: column; + position: relative; + border-right: var(--cell-border); + z-index: 3; } /* Add shadow when scrolled */ - .sticky-column.scrolled :global(.cell:last-child:after) { - /*content: " ";*/ - /*position: absolute;*/ - /*width: 10px;*/ - /*height: 100%;*/ - /*left: 100%;*/ - /*background: linear-gradient(to right, rgba(0, 0, 0, 0.08), transparent);*/ + .sticky-column.scrolled { + box-shadow: 0 0 8px -2px rgba(0, 0, 0, 0.2); } /* Don't show borders between cells in the sticky column */ @@ -178,8 +176,7 @@ } .header { - position: relative; - z-index: 3; + z-index: 1; } .header :global(.cell) { background: var(--spectrum-global-color-gray-100); @@ -192,7 +189,6 @@ } .content { position: relative; - z-index: 1; flex: 1 1 auto; } diff --git a/packages/frontend-core/src/components/sheet/overlays/MenuOverlay.svelte b/packages/frontend-core/src/components/sheet/overlays/MenuOverlay.svelte index 8392bff7be..5c0c43c13d 100644 --- a/packages/frontend-core/src/components/sheet/overlays/MenuOverlay.svelte +++ b/packages/frontend-core/src/components/sheet/overlays/MenuOverlay.svelte @@ -57,7 +57,6 @@ diff --git a/packages/frontend-core/src/components/sheet/overlays/ResizeOverlay.svelte b/packages/frontend-core/src/components/sheet/overlays/ResizeOverlay.svelte index 40644fd669..ea7de5edfd 100644 --- a/packages/frontend-core/src/components/sheet/overlays/ResizeOverlay.svelte +++ b/packages/frontend-core/src/components/sheet/overlays/ResizeOverlay.svelte @@ -51,7 +51,6 @@ .resize-slider { position: absolute; top: 0; - z-index: 2; height: var(--row-height); opacity: 0; padding: 0 8px; diff --git a/packages/frontend-core/src/components/sheet/overlays/ScrollOverlay.svelte b/packages/frontend-core/src/components/sheet/overlays/ScrollOverlay.svelte index f95b5d617d..5478ec7c63 100644 --- a/packages/frontend-core/src/components/sheet/overlays/ScrollOverlay.svelte +++ b/packages/frontend-core/src/components/sheet/overlays/ScrollOverlay.svelte @@ -109,7 +109,6 @@ background: var(--spectrum-global-color-gray-500); opacity: 0.7; border-radius: 4px; - z-index: 1; transition: opacity 130ms ease-out; } div:hover { diff --git a/packages/frontend-core/src/components/sheet/stores/max-scroll.js b/packages/frontend-core/src/components/sheet/stores/max-scroll.js index 9cf09703e3..f05dfd4c34 100644 --- a/packages/frontend-core/src/components/sheet/stores/max-scroll.js +++ b/packages/frontend-core/src/components/sheet/stores/max-scroll.js @@ -1,4 +1,5 @@ import { derived, get } from "svelte/store" +import { tick } from "svelte" export const createMaxScrollStores = context => { const { @@ -88,65 +89,68 @@ export const createMaxScrollStores = context => { }) // Ensure the selected cell is visible - selectedCellRow.subscribe(row => { - if (!row) { - return - } + selectedCellId.subscribe(async $selectedCellId => { + await tick() + const $selectedCellRow = get(selectedCellRow) const $scroll = get(scroll) const $bounds = get(bounds) const $rowHeight = get(rowHeight) - const scrollBarOffset = 16 + const verticalOffset = $rowHeight * 1.5 - // Ensure row is not below bottom of screen - const rowYPos = row.__idx * $rowHeight - const bottomCutoff = - $scroll.top + $bounds.height - $rowHeight - scrollBarOffset - let delta = rowYPos - bottomCutoff - if (delta > 0) { - scroll.update(state => ({ - ...state, - top: state.top + delta, - })) - } - - // Ensure row is not above top of screen - else { - delta = $scroll.top - rowYPos + // Ensure vertical position is viewable + if ($selectedCellRow) { + // Ensure row is not below bottom of screen + const rowYPos = $selectedCellRow.__idx * $rowHeight + const bottomCutoff = + $scroll.top + $bounds.height - $rowHeight - verticalOffset + let delta = rowYPos - bottomCutoff if (delta > 0) { scroll.update(state => ({ ...state, - top: Math.max(0, state.top - delta), + top: state.top + delta, })) } + + // Ensure row is not above top of screen + else { + const delta = $scroll.top - rowYPos + verticalOffset + if (delta > 0) { + scroll.update(state => ({ + ...state, + top: Math.max(0, state.top - delta), + })) + } + } } + // Ensure horizontal position is viewable // Check horizontal position of columns next - const $selectedCellId = get(selectedCellId) const $visibleColumns = get(visibleColumns) const columnName = $selectedCellId?.split("-")[1] const column = $visibleColumns.find(col => col.name === columnName) + const horizontalOffset = 24 if (!column) { return } // Ensure column is not cutoff on left edge - delta = $scroll.left - column.left + let delta = $scroll.left - column.left + horizontalOffset if (delta > 0) { scroll.update(state => ({ ...state, - left: state.left - delta, + left: Math.max(0, state.left - delta), })) } // Ensure column is not cutoff on right edge else { const rightEdge = column.left + column.width - const rightBound = $bounds.width + $scroll.left + const rightBound = $bounds.width + $scroll.left - horizontalOffset delta = rightEdge - rightBound if (delta > 0) { scroll.update(state => ({ ...state, - left: state.left + delta + scrollBarOffset, + left: state.left + delta, })) } } diff --git a/packages/frontend-core/src/components/sheet/stores/ui.js b/packages/frontend-core/src/components/sheet/stores/ui.js index d1687c581e..f3332b306d 100644 --- a/packages/frontend-core/src/components/sheet/stores/ui.js +++ b/packages/frontend-core/src/components/sheet/stores/ui.js @@ -8,7 +8,7 @@ export const createUIStores = context => { const selectedCellAPI = writable(null) const rowHeight = writable(36) - // Derive the row that contains the selected cell. + // Derive the row that contains the selected cell const selectedCellRow = derived( [selectedCellId, rowLookupMap, rows], ([$selectedCellId, $rowLookupMap, $rows]) => {