From f516011182ea7a626f880a60d964224e0b206c9c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 7 Mar 2023 08:23:50 +0000 Subject: [PATCH] Handle context menu events in header cells --- .../components/sheet/cells/HeaderCell.svelte | 26 +++++++++++++------ .../components/sheet/cells/SheetCell.svelte | 1 + 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/frontend-core/src/components/sheet/cells/HeaderCell.svelte b/packages/frontend-core/src/components/sheet/cells/HeaderCell.svelte index 2780d73a9c..5b113b4d48 100644 --- a/packages/frontend-core/src/components/sheet/cells/HeaderCell.svelte +++ b/packages/frontend-core/src/components/sheet/cells/HeaderCell.svelte @@ -18,14 +18,23 @@ $: canMoveLeft = orderable && column.idx > 0 $: canMoveRight = orderable && column.idx < $columns.length - 1 - const startReordering = e => { - timeout = setTimeout(() => { - reorder.actions.startReordering(column.name, e) - }, 200) + const onMouseDown = e => { + if (e.button === 0 && orderable) { + timeout = setTimeout(() => { + reorder.actions.startReordering(column.name, e) + }, 200) + } } - const stopReordering = () => { - clearTimeout(timeout) + const onMouseUp = e => { + if (e.button === 0 && orderable) { + clearTimeout(timeout) + } + } + + const onContextMenu = e => { + e.preventDefault() + open = true } const sortAscending = () => { @@ -66,8 +75,9 @@ diff --git a/packages/frontend-core/src/components/sheet/cells/SheetCell.svelte b/packages/frontend-core/src/components/sheet/cells/SheetCell.svelte index 39282c821b..7764022f48 100644 --- a/packages/frontend-core/src/components/sheet/cells/SheetCell.svelte +++ b/packages/frontend-core/src/components/sheet/cells/SheetCell.svelte @@ -39,6 +39,7 @@ on:mousedown on:mouseup on:click + on:contextmenu {style} data-row={rowIdx} >