diff --git a/packages/frontend-core/src/components/sheet/overlays/KeyboardManager.svelte b/packages/frontend-core/src/components/sheet/overlays/KeyboardManager.svelte
index 008bd513d6..21b65c4f18 100644
--- a/packages/frontend-core/src/components/sheet/overlays/KeyboardManager.svelte
+++ b/packages/frontend-core/src/components/sheet/overlays/KeyboardManager.svelte
@@ -1,6 +1,7 @@
-{#if showVScrollbar}
+{#if $showVScrollbar}
{/if}
-{#if showHScrollbar}
+{#if $showHScrollbar}
{/if}
@@ -110,21 +106,19 @@
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 0665ba31b2..e54386cb8c 100644
--- a/packages/frontend-core/src/components/sheet/stores/max-scroll.js
+++ b/packages/frontend-core/src/components/sheet/stores/max-scroll.js
@@ -17,6 +17,7 @@ export const createMaxScrollStores = context => {
// Memoize store primitives
const scrollTop = derived(scroll, $scroll => $scroll.top, 0)
const scrollLeft = derived(scroll, $scroll => $scroll.left, 0)
+ const stickyColumnWidth = derived(stickyColumn, $col => $col?.width || 0, 0)
// Derive vertical limits
const height = derived(bounds, $bounds => $bounds.height, 0)
@@ -34,9 +35,9 @@ export const createMaxScrollStores = context => {
// Derive horizontal limits
const contentWidth = derived(
- [visibleColumns, stickyColumn],
- ([$visibleColumns, $stickyColumn]) => {
- let width = gutterWidth + padding + ($stickyColumn?.width || 0)
+ [visibleColumns, stickyColumnWidth],
+ ([$visibleColumns, $stickyColumnWidth]) => {
+ let width = gutterWidth + padding + $stickyColumnWidth
$visibleColumns.forEach(col => {
width += col.width
})
@@ -45,9 +46,8 @@ export const createMaxScrollStores = context => {
0
)
const screenWidth = derived(
- [width, stickyColumn],
- ([$width, $stickyColumn]) =>
- $width + gutterWidth + ($stickyColumn?.width || 0),
+ [width, stickyColumnWidth],
+ ([$width, $stickyColumnWidth]) => $width + gutterWidth + $stickyColumnWidth,
0
)
const maxScrollLeft = derived(
@@ -151,10 +151,27 @@ export const createMaxScrollStores = context => {
}
})
+ // Derive whether to show scrollbars or not
+ const showVScrollbar = derived(
+ [contentHeight, height],
+ ([$contentHeight, $height]) => {
+ return $contentHeight > $height
+ }
+ )
+ const showHScrollbar = derived(
+ [contentWidth, screenWidth],
+ ([$contentWidth, $screenWidth]) => {
+ return $contentWidth > $screenWidth
+ }
+ )
+
return {
contentHeight,
contentWidth,
+ screenWidth,
maxScrollTop,
maxScrollLeft,
+ showHScrollbar,
+ showVScrollbar,
}
}
diff --git a/packages/frontend-core/src/components/sheet/stores/rows.js b/packages/frontend-core/src/components/sheet/stores/rows.js
index 4cc230a77d..a62259eccc 100644
--- a/packages/frontend-core/src/components/sheet/stores/rows.js
+++ b/packages/frontend-core/src/components/sheet/stores/rows.js
@@ -120,7 +120,7 @@ export const createRowsStore = context => {
return index >= 0 ? get(enrichedRows)[index] : null
}
- // Adds a new empty row
+ // Adds a new row
const addRow = async (row, idx) => {
try {
// Create row
@@ -136,6 +136,7 @@ export const createRowsStore = context => {
} else {
handleNewRows([newRow])
}
+ notifications.success("Row added successfully")
return newRow
} catch (error) {
notifications.error(`Error adding row: ${error?.message}`)
diff --git a/packages/frontend-core/src/components/sheet/stores/viewport.js b/packages/frontend-core/src/components/sheet/stores/viewport.js
index 27341a7cfe..b1abb6e1a4 100644
--- a/packages/frontend-core/src/components/sheet/stores/viewport.js
+++ b/packages/frontend-core/src/components/sheet/stores/viewport.js
@@ -11,7 +11,7 @@ export const createViewportStores = context => {
// Derive visible rows
// Split into multiple stores containing primitives to optimise invalidation
- // as mich as possible
+ // as much as possible
const scrolledRowCount = derived(
scrollTop,
$scrollTop => {
@@ -22,7 +22,7 @@ export const createViewportStores = context => {
const visualRowCapacity = derived(
height,
$height => {
- return Math.ceil($height / cellHeight)
+ return Math.ceil($height / cellHeight) + 1
},
0
)
diff --git a/packages/frontend-core/src/components/sheet/stores/wheel.js b/packages/frontend-core/src/components/sheet/stores/wheel.js
new file mode 100644
index 0000000000..45938bbdf3
--- /dev/null
+++ b/packages/frontend-core/src/components/sheet/stores/wheel.js
@@ -0,0 +1,53 @@
+import { get } from "svelte/store"
+import { domDebounce } from "../../../utils/utils"
+
+export const createWheelStores = context => {
+ const {
+ maxScrollLeft,
+ maxScrollTop,
+ hoveredRowId,
+ renderedRows,
+ bounds,
+ scroll,
+ cellHeight,
+ } = context
+
+ // Handles a wheel even and updates the scroll offsets
+ const handleWheel = e => {
+ e.preventDefault()
+ const modifier = e.ctrlKey || e.metaKey
+ let x = modifier ? e.deltaY : e.deltaX
+ let y = modifier ? e.deltaX : e.deltaY
+ debouncedHandleWheel(x, y, e.clientY)
+ }
+ const debouncedHandleWheel = domDebounce((deltaX, deltaY, clientY) => {
+ const { top, left } = get(scroll)
+
+ // Calculate new scroll top
+ let newScrollTop = top + deltaY
+ newScrollTop = Math.max(0, Math.min(newScrollTop, get(maxScrollTop)))
+
+ // Calculate new scroll left
+ let newScrollLeft = left + deltaX
+ newScrollLeft = Math.max(0, Math.min(newScrollLeft, get(maxScrollLeft)))
+
+ // Update state
+ scroll.set({
+ left: newScrollLeft,
+ top: newScrollTop,
+ })
+
+ // Hover row under cursor
+ const y = clientY - get(bounds).top + (newScrollTop % cellHeight)
+ const hoveredRow = get(renderedRows)[Math.floor(y / cellHeight)]
+ hoveredRowId.set(hoveredRow?._id)
+ })
+
+ return {
+ wheel: {
+ actions: {
+ handleWheel,
+ },
+ },
+ }
+}