@jinaan/uikit 0.1.49 → 0.1.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinaan/uikit",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -441,16 +441,7 @@ export function DataTable<T>({
441
441
  useLayoutEffect(() => {
442
442
  const table = bodyTableRef.current;
443
443
  if (!table) return;
444
- if (structureRef.current !== structureKey || contentRef.current !== contentKey) {
445
- // Column set or row content changed: drop the pinned widths so the body
446
- // re-renders content-sized (table-auto) and the next pass measures
447
- // intrinsic widths again. Without this, the effect would measure the
448
- // stale colgroup's shifted layout and pin the wrong (truncating) widths.
449
- structureRef.current = structureKey;
450
- contentRef.current = contentKey;
451
- setColumnWidths((prev) => (prev.length === 0 ? prev : []));
452
- return;
453
- }
444
+
454
445
  const measure = () => {
455
446
  const cells = table.tBodies[0]?.rows.item(0)?.cells;
456
447
  if (!cells || cells.length === 0) {
@@ -481,6 +472,23 @@ export function DataTable<T>({
481
472
  prev.length === widths.length && prev.every((w, i) => w === widths[i]) ? prev : widths,
482
473
  );
483
474
  };
475
+ if (structureRef.current !== structureKey || contentRef.current !== contentKey) {
476
+ // Column set or row content changed: drop the pinned widths so the body
477
+ // re-renders content-sized (table-auto) and the next pass measures
478
+ // intrinsic widths again. Without this, the effect would measure the
479
+ // stale colgroup's shifted layout and pin the wrong (truncating) widths.
480
+ structureRef.current = structureKey;
481
+ contentRef.current = contentKey;
482
+ if (pinned) {
483
+ // The widths -> [] state flip re-runs this effect (see `pinned` in the
484
+ // deps); measuring now would read the still-pinned layout.
485
+ setColumnWidths([]);
486
+ return;
487
+ }
488
+ // Already unpinned: no state flip would re-run the effect, so measure
489
+ // the content-sized layout right away.
490
+ }
491
+
484
492
  measure();
485
493
  syncBandScroll();
486
494
  if (typeof ResizeObserver === "undefined") return;