From c23dfa06215255845975d5210311d244e1ff7e99 Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 27 Oct 2025 18:32:28 +0530 Subject: [PATCH] revert: unfinished changes. --- .../(suggestions)/empty.svelte | 124 +++++------------- 1 file changed, 32 insertions(+), 92 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte index 9033ca773..9fd67fb9d 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte @@ -49,16 +49,6 @@ userColumns?: Column[]; } = $props(); - const staticUserColumns = userColumns.map((column) => { - return { - ...column, - resizable: false, - draggable: false - }; - }); - - console.log(JSON.stringify(staticUserColumns, null, 2)); - let resizeObserver: ResizeObserver; let spreadsheetContainer: HTMLElement; @@ -173,32 +163,15 @@ if (!hasRealColumns) { // for placeholders or no columns, // position overlay to cover custom columns area - let startCell = getById('$id'); - - if (staticUserColumns.length > 0) { - const lastUserColumn = userColumns[staticUserColumns.length - 1]; - let lastUserCell = getById(lastUserColumn.id); - - // If not found with data-header="true", try without it - if (!lastUserCell) { - lastUserCell = headerElement!.querySelector( - `[role="cell"][data-column-id="${lastUserColumn.id}"]` - ); - } - - if (lastUserCell) { - startCell = lastUserCell; - } - } - + const idCell = getById('$id'); const actionsCell = headerElement!.querySelector( '[role="cell"][data-column-id="actions"]' ); - if (startCell && actionsCell) { - const startRect = startCell.getBoundingClientRect(); + if (idCell && actionsCell) { + const idRect = idCell.getBoundingClientRect(); const actionsRect = actionsCell.getBoundingClientRect(); - const left = Math.round(startRect.right - containerRect.left); + const left = Math.round(idRect.right - containerRect.left); const actionsLeft = actionsRect.left - containerRect.left; const width = actionsLeft - left; @@ -253,30 +226,12 @@ .querySelector('[data-select="true"]') ?.getBoundingClientRect(); - // determine starting point for overlay + // Start overlay after selection column if it exists, otherwise after $id let startLeft = idRect.right; if (selectionRect && selectionRect.right > idRect.right) { startLeft = selectionRect.right; } - // If userColumns exist, start overlay after the last userColumn instead - if (staticUserColumns.length > 0) { - const lastUserColumn = userColumns[staticUserColumns.length - 1]; - let lastUserCell = getById(lastUserColumn.id); - - // If not found with data-header="true", try without it (cell might be rendered differently) - if (!lastUserCell) { - lastUserCell = headerElement!.querySelector( - `[role="cell"][data-column-id="${lastUserColumn.id}"]` - ); - } - - if (lastUserCell) { - const lastUserRect = lastUserCell.getBoundingClientRect(); - startLeft = lastUserRect.right; - } - } - const left = Math.round(startLeft - containerRect.left); // get the actions column and use its left border as the boundary @@ -303,37 +258,26 @@ // only for mobile, we can remove if not needed! const scrollToFirstCustomColumn = () => { - if (!staticUserColumns.length && !$isSmallViewport) return; + if (!$isSmallViewport) return; if (!headerElement || !headerElement.isConnected) { - headerElement = spreadsheetContainer?.querySelector('[role="rowheader"]'); + headerElement = spreadsheetContainer.querySelector('[role="rowheader"]'); } if (!headerElement) return; + const firstCustomColumnCell = headerElement.querySelector( + `[role="cell"][data-header="true"][data-column-id="${customColumns[0]?.key}"]` + ); + const directAccessScroller = hScroller ?? findHorizontalScroller(headerElement) ?? // internal spreadsheet root main container! spreadsheetContainer.querySelector('.spreadsheet-container'); - if (!directAccessScroller) return; - - let targetCell: HTMLElement | null = null; - - if (staticUserColumns.length > 0) { - const lastUserColumn = userColumns[staticUserColumns.length - 1]; - targetCell = headerElement.querySelector( - `[role="cell"][data-header="true"][data-column-id="${lastUserColumn.id}"]` - ); - } else { - targetCell = headerElement.querySelector( - `[role="cell"][data-header="true"][data-column-id="${customColumns[0]?.key}"]` - ); - } - - if (targetCell) { - const cellRect = targetCell.getBoundingClientRect(); + if (firstCustomColumnCell && directAccessScroller) { + const cellRect = firstCustomColumnCell.getBoundingClientRect(); const scrollerRect = directAccessScroller.getBoundingClientRect(); const scrollLeft = directAccessScroller.scrollLeft + cellRect.left - scrollerRect.left - 40; @@ -465,8 +409,8 @@ icon: IconFingerPrint, ...baseColProps }, - ...staticUserColumns, ...finalCustomColumns, + /*...userColumns,*/ { id: 'actions', title: '', @@ -482,6 +426,8 @@ const emptyCells = $derived(($isSmallViewport ? 14 : 17) + (!$expandTabs ? 2 : 0)); onMount(async () => { + userColumns; /* silences lint check, variable not read */ + if (spreadsheetContainer) { resizeObserver = new ResizeObserver(recalcAll); resizeObserver.observe(spreadsheetContainer); @@ -514,8 +460,10 @@ async function suggestColumns() { $tableColumnSuggestions.thinking = true; - await tick(); - scrollToFirstCustomColumn(); + if ($isSmallViewport) { + await tick(); + scrollToFirstCustomColumn(); + } let suggestedColumns: { total: number; @@ -1083,23 +1031,6 @@ } }); - // mark suggested column cells so CSS can target them specifically - $effect(() => { - if (!spreadsheetContainer) return; - - // get all custom column IDs - const suggestedColumnIds = customColumns.map((col) => col.key); - const allCells = spreadsheetContainer.querySelectorAll('[role="cell"][data-column-id]'); - allCells.forEach((cell) => { - const columnId = cell.getAttribute('data-column-id'); - if (columnId && suggestedColumnIds.includes(columnId)) { - cell.setAttribute('data-suggested-column', 'true'); - } else { - cell.removeAttribute('data-suggested-column'); - } - }); - }); - $effect(() => { if (!spreadsheetContainer) return; @@ -1676,7 +1607,12 @@ } &:has(.columns-range-overlay) { - :global([role='rowheader'][data-suggested-column='true']) { + :global( + [role='rowheader'] + [role='cell']:has(.column-resizer-disabled):not([data-column-id^='$']):not( + [data-column-id='actions'] + ) + ) { background: var(--columns-range-pink-header-background-color); } @@ -1689,12 +1625,16 @@ margin-left: -2px; } - :global([role='cell']:has(.column-resizer-disabled)[data-suggested-column='true']) { + :global( + [role='cell']:has(.column-resizer-disabled):not([data-column-id^='$']):not( + [data-column-id='actions'] + ) + ) { box-shadow: 0 -1px 0 0 var(--columns-range-pink-border-color) inset !important; transition: box-shadow 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); } - :global([role='cell'][data-suggested-column='true'] .column-resizer-disabled) { + :global([role='cell']:not([data-column-id='actions']) .column-resizer-disabled) { border-left: var(--border-width-s, 1px) solid var(--columns-range-pink-border-color) !important; transition: border-color 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); }