@omnigrid/react 0.1.8 → 0.1.9
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.
- package/dist/OmniGrid.js +16 -5
- package/package.json +1 -1
package/dist/OmniGrid.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
3
4
|
import { DomPool } from "@omnigrid/core";
|
|
4
5
|
import { contentToReactNode } from "./content";
|
|
5
6
|
import { computeGroupSegments } from "./groupHeader";
|
|
@@ -285,7 +286,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
285
286
|
* React effects (structural changes) and directly from the scroll rAF
|
|
286
287
|
* handler (imperative, no React re-render).
|
|
287
288
|
*/
|
|
288
|
-
const syncPool = () => {
|
|
289
|
+
const syncPool = (synchronousColumnWindow = false) => {
|
|
289
290
|
const state = grid.getState();
|
|
290
291
|
const currentViewportData = grid.getViewportData();
|
|
291
292
|
const pinnedLeftWidth = currentViewportData.pinnedLeftColumns.reduce((sum, item) => sum + item.width, 0);
|
|
@@ -314,9 +315,19 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
314
315
|
const columnWindowKey = `${currentViewportData.columnRange.start}:${currentViewportData.columnRange.end}:${state.viewport.width}:${pinnedLeftWidth}:${pinnedRightWidth}`;
|
|
315
316
|
if (columnWindowKey !== columnWindowKeyRef.current) {
|
|
316
317
|
columnWindowKeyRef.current = columnWindowKey;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
const updateColumnWindow = () => {
|
|
319
|
+
for (const pane of layers.central.panes)
|
|
320
|
+
pane.updateColumns(layers.central.columns, layers.central.originX);
|
|
321
|
+
setColumnWindowVersion((v) => v + 1);
|
|
322
|
+
};
|
|
323
|
+
if (synchronousColumnWindow) {
|
|
324
|
+
// Keep React-rendered cell content and headers in step with the
|
|
325
|
+
// imperative cell repositioning before the browser paints.
|
|
326
|
+
flushSync(updateColumnWindow);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
updateColumnWindow();
|
|
330
|
+
}
|
|
320
331
|
}
|
|
321
332
|
};
|
|
322
333
|
/**
|
|
@@ -434,7 +445,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
434
445
|
// so this does NOT trigger a React re-render. The DomPool is
|
|
435
446
|
// updated imperatively below.
|
|
436
447
|
grid.setViewport({ scrollTop, scrollLeft });
|
|
437
|
-
syncPool();
|
|
448
|
+
syncPool(true);
|
|
438
449
|
});
|
|
439
450
|
};
|
|
440
451
|
if (!isMeasured) {
|