From 443be4cdab85c4a6d0083f3b16d34d6cdb86dde9 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 24 Apr 2024 16:28:44 +0100 Subject: [PATCH] More upgrades to grids to support new popovers and use popovers for options cells --- .../backend/DataTable/TableDataTable.svelte | 2 +- .../src/components/grid/cells/DateCell.svelte | 33 ++++-------- .../components/grid/cells/OptionsCell.svelte | 51 ++++++++----------- .../grid/layout/GridScrollWrapper.svelte | 4 ++ .../grid/overlays/GridPopover.svelte | 38 +++++--------- .../grid/overlays/ScrollOverlay.svelte | 10 ++-- .../src/components/grid/stores/reorder.js | 2 +- 7 files changed, 56 insertions(+), 84 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte index 6a5cd2f282..fe393c5268 100644 --- a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte @@ -101,7 +101,7 @@ diff --git a/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte b/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte index 158451c930..81882c867c 100644 --- a/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/OptionsCell.svelte @@ -1,7 +1,8 @@ - -{@html markup} - +
dispatch("close")}> + +
+ + diff --git a/packages/frontend-core/src/components/grid/overlays/ScrollOverlay.svelte b/packages/frontend-core/src/components/grid/overlays/ScrollOverlay.svelte index c256e0dc19..b10f245fcb 100644 --- a/packages/frontend-core/src/components/grid/overlays/ScrollOverlay.svelte +++ b/packages/frontend-core/src/components/grid/overlays/ScrollOverlay.svelte @@ -17,6 +17,7 @@ height, isDragging, menu, + focusedCellAPI, } = getContext("grid") // State for dragging bars @@ -47,10 +48,11 @@ $: barLeft = ScrollBarSize + availWidth * ($scrollLeft / $maxScrollLeft) // Helper to close the context menu if it's open - const closeMenu = () => { + const closePopovers = () => { if ($menu.visible) { menu.actions.close() } + $focusedCellAPI?.blur() } const getLocation = e => { @@ -70,7 +72,7 @@ document.addEventListener("mouseup", stopVDragging) document.addEventListener("touchend", stopVDragging) isDraggingV = true - closeMenu() + closePopovers() } const moveVDragging = domDebounce(e => { const delta = getLocation(e).y - initialMouse @@ -99,7 +101,7 @@ document.addEventListener("mouseup", stopHDragging) document.addEventListener("touchend", stopHDragging) isDraggingH = true - closeMenu() + closePopovers() } const moveHDragging = domDebounce(e => { const delta = getLocation(e).x - initialMouse @@ -127,7 +129,6 @@ on:mousedown={startVDragging} on:touchstart={startVDragging} class:dragging={isDraggingV} - data-ignore-click-outside="true" /> {/if} {#if $showHScrollbar} @@ -138,7 +139,6 @@ on:mousedown={startHDragging} on:touchstart={startHDragging} class:dragging={isDraggingH} - data-ignore-click-outside="true" /> {/if} diff --git a/packages/frontend-core/src/components/grid/stores/reorder.js b/packages/frontend-core/src/components/grid/stores/reorder.js index f820593174..fed9f4c6ef 100644 --- a/packages/frontend-core/src/components/grid/stores/reorder.js +++ b/packages/frontend-core/src/components/grid/stores/reorder.js @@ -87,7 +87,7 @@ export const createActions = context => { // Check if we need to start auto-scrolling const $reorder = get(reorder) const proximityCutoff = 140 - const speedFactor = 8 + const speedFactor = 16 const rightProximity = Math.max(0, $reorder.gridLeft + $reorder.width - x) const leftProximity = Math.max(0, x - $reorder.gridLeft) if (rightProximity < proximityCutoff) {