1
0
Fork 0
mirror of synced 2024-09-13 07:53:31 +12:00

Fix bug where button columns couldn't observe dimensions when no rows exist

This commit is contained in:
Andrew Kingston 2024-05-29 08:47:57 +01:00
parent 1a83b746b5
commit 35842525c5
2 changed files with 5 additions and 5 deletions

View file

@ -19,7 +19,7 @@
showVScrollbar,
} = getContext("grid")
let measureContainer
let container
$: buttons = $props.buttons?.slice(0, 3) || []
$: columnsWidth = $visibleColumns.reduce(
@ -40,7 +40,7 @@
const width = entries?.[0]?.contentRect?.width ?? 0
buttonColumnWidth.set(width)
})
observer.observe(measureContainer)
observer.observe(container)
})
</script>
@ -51,7 +51,7 @@
class:hidden={$buttonColumnWidth === 0}
>
<div class="content" on:mouseleave={() => ($hoveredRowId = null)}>
<GridScrollWrapper scrollVertically attachHandlers>
<GridScrollWrapper scrollVertically attachHandlers bind:ref={container}>
{#each $renderedRows as row}
{@const rowSelected = !!$selectedRows[row._id]}
{@const rowHovered = $hoveredRowId === row._id}
@ -60,7 +60,6 @@
class="row"
on:mouseenter={$isDragging ? null : () => ($hoveredRowId = row._id)}
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
bind:this={measureContainer}
>
<GridCell
width="auto"

View file

@ -18,6 +18,7 @@
export let scrollVertically = false
export let scrollHorizontally = false
export let attachHandlers = false
export let ref
// Used for tracking touch events
let initialTouchX
@ -109,7 +110,7 @@
on:touchmove={attachHandlers ? handleTouchMove : null}
on:click|self={() => ($focusedCellId = null)}
>
<div {style} class="inner">
<div {style} class="inner" bind:this={ref}>
<slot />
</div>
</div>