@omnigrid/react 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/OmniGrid.js +10 -2
  2. package/package.json +1 -1
package/dist/OmniGrid.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { DomPool } from "@omnigrid/core";
4
4
  import { contentToReactNode } from "./content";
5
5
  import { computeGroupSegments } from "./groupHeader";
@@ -91,7 +91,6 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
91
91
  const renderContext = useMemo(() => ({ api: grid, state, slot: undefined }), [grid, state]);
92
92
  const buildRenderContext = useCallback(() => renderContext, [renderContext]);
93
93
  const autoHeight = style?.height === undefined;
94
- const verticalScrollbarGutter = autoHeight ? "auto" : "stable";
95
94
  const rowHeight = grid.getState().rowHeight;
96
95
  // Column-group header stack: `headerRowCount` group rows (one per depth) above
97
96
  // the leaf header row. Without groups `headerRowCount` is 0 and `columnGroupDepth`
@@ -114,6 +113,8 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
114
113
  * group cell already sits directly above the leaf row.
115
114
  */
116
115
  const measuredHeight = viewportData.totalHeight + headerHeight;
116
+ const hasVerticalOverflow = !autoHeight && measuredHeight > state.viewport.height;
117
+ const verticalScrollbarGutter = hasVerticalOverflow ? "stable" : "auto";
117
118
  const viewportStyle = { ...style, height: autoHeight ? measuredHeight : style?.height };
118
119
  const suppressRowHoverHighlight = options.suppressRowHoverHighlight ?? false;
119
120
  const viewportClassName = ["omnigrid", className, suppressRowHoverHighlight ? "omnigrid-no-row-hover" : null].filter(Boolean).join(" ");
@@ -362,6 +363,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
362
363
  measureViewport();
363
364
  return () => observer.disconnect();
364
365
  }, [grid, measureViewport]);
366
+ useLayoutEffect(() => {
367
+ if (!isMeasured || autoHeight)
368
+ return;
369
+ // Gutter changes alter clientWidth; sync it before paint so columns
370
+ // cannot render underneath a newly visible vertical scrollbar.
371
+ measureViewport();
372
+ }, [autoHeight, hasVerticalOverflow, isMeasured, measureViewport]);
365
373
  /**
366
374
  * Sync the DomPool after every structural re-render.
367
375
  * This runs only when React actually re-renders (data / columns /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/react",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "React adapter and renderer for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",