@shival99/z-ui 1.7.11 → 1.7.13

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.
@@ -3547,7 +3547,10 @@ class ZTableComponent {
3547
3547
  const totalRows = untracked(() => this.table.getRowModel().rows.length);
3548
3548
  return Math.ceil(totalRows / this.groupSize());
3549
3549
  }, ...(ngDevMode ? [{ debugName: "_virtualGroupCount" }] : []));
3550
+ _virtualResetVersion = signal(0, ...(ngDevMode ? [{ debugName: "_virtualResetVersion" }] : []));
3550
3551
  virtualizer = injectVirtualizer(() => {
3552
+ // Track reset version to force virtualizer re-initialization
3553
+ this._virtualResetVersion();
3551
3554
  const groups = this.dynamicGroups();
3552
3555
  const rowHeight = this.virtualRowHeight();
3553
3556
  const groupSize = this.groupSize();
@@ -3567,6 +3570,7 @@ class ZTableComponent {
3567
3570
  },
3568
3571
  measureElement: (element) => element.getBoundingClientRect().height,
3569
3572
  overscan: this._virtualConfig().overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3573
+ initialOffset: 0,
3570
3574
  };
3571
3575
  });
3572
3576
  _measureVirtualItems = effect(() => {
@@ -3693,6 +3697,7 @@ class ZTableComponent {
3693
3697
  });
3694
3698
  explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting, this._data], () => {
3695
3699
  if (this.isVirtual()) {
3700
+ // Reset scroll position synchronously
3696
3701
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3697
3702
  if (wrapperEl) {
3698
3703
  wrapperEl.scrollTop = 0;
@@ -3701,14 +3706,16 @@ class ZTableComponent {
3701
3706
  if (scrollbar) {
3702
3707
  void scrollbar.scrollTo({ top: 0, duration: 0 });
3703
3708
  }
3709
+ // Reset virtualizer to offset 0
3704
3710
  this.virtualizer.scrollToOffset(0);
3711
+ // Force recalculate dynamic groups immediately
3712
+ this._dynamicGroupsVersion.update(v => v + 1);
3713
+ // Force virtualizer to reset with initialOffset: 0
3714
+ this._virtualResetVersion.update(v => v + 1);
3705
3715
  }
3706
3716
  queueMicrotask(() => {
3707
3717
  this._checkVerticalScroll();
3708
3718
  this._checkHorizontalScroll();
3709
- if (this.isVirtual()) {
3710
- this._dynamicGroupsVersion.update(v => v + 1);
3711
- }
3712
3719
  });
3713
3720
  });
3714
3721
  explicitEffect([this.virtualizer.getVirtualItems], () => {
@@ -3729,12 +3736,19 @@ class ZTableComponent {
3729
3736
  }
3730
3737
  return;
3731
3738
  }
3739
+ // Loading finished - reset scroll positions
3732
3740
  queueMicrotask(() => {
3733
3741
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3734
3742
  if (wrapperEl) {
3735
3743
  wrapperEl.scrollTop = 0;
3736
3744
  wrapperEl.scrollLeft = this._savedScrollLeft();
3737
3745
  }
3746
+ // Critical: Reset virtualizer when loading finishes in server mode
3747
+ if (this.isVirtual()) {
3748
+ this.virtualizer.scrollToOffset(0);
3749
+ this._dynamicGroupsVersion.update(v => v + 1);
3750
+ this._virtualResetVersion.update(v => v + 1);
3751
+ }
3738
3752
  this._checkScrollState();
3739
3753
  });
3740
3754
  });