@acorex/components 22.4.28 → 22.4.30

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.
@@ -494,6 +494,8 @@ class AXLookupListViewBase {
494
494
  return this.totalCount();
495
495
  }
496
496
  #ngZone;
497
+ /** When true, scroll the selected row into view once after open or after a refreshed result set. */
498
+ #pendingSelectedScroll;
497
499
  /**
498
500
  * Before the first page loads, `totalCount` is 0 but `cachedItems` is pre-sized to `pageSize`.
499
501
  * After a completed load with no rows, `cachedItems` is an empty array.
@@ -608,6 +610,8 @@ class AXLookupListViewBase {
608
610
  this.navItems = viewChildren(AXListNavigationItemDirective, /* @ts-ignore */
609
611
  ...(ngDevMode ? [{ debugName: "navItems" }] : /* istanbul ignore next */ []));
610
612
  this.#ngZone = inject(NgZone);
613
+ /** When true, scroll the selected row into view once after open or after a refreshed result set. */
614
+ this.#pendingSelectedScroll = true;
611
615
  this.trackByIndex = (index) => index;
612
616
  // CDK measures the viewport size only once, when it initializes. Inside the popover the
613
617
  // panel is still animating/positioning at that moment (and the height also changes when
@@ -632,10 +636,14 @@ class AXLookupListViewBase {
632
636
  this.totalCount.set(source.totalCount);
633
637
  this.#syncLoadingState(source, source.isLoading);
634
638
  this.listDataSource.set(list);
639
+ this.#pendingSelectedScroll = true;
635
640
  });
636
641
  const loadingSub = source.onLoadingChanged.subscribe((value) => this.#syncLoadingState(source, value));
637
642
  const changedSub = source.onChanged.subscribe((e) => {
638
643
  this.totalCount.set(e.totalCount);
644
+ if (e.page === 0) {
645
+ this.#pendingSelectedScroll = true;
646
+ }
639
647
  if (!source.isLoading) {
640
648
  this.#syncLoadingState(source, false);
641
649
  }
@@ -645,7 +653,7 @@ class AXLookupListViewBase {
645
653
  changedSub.unsubscribe();
646
654
  });
647
655
  });
648
- // Scroll the selected row into view once the virtual viewport and data are ready.
656
+ // Scroll the selected row into view once per open / refreshed result set (not on every page load).
649
657
  effect(() => {
650
658
  const viewport = this.viewportRef();
651
659
  const loading = this.isLoading();
@@ -654,7 +662,14 @@ class AXLookupListViewBase {
654
662
  const field = this.valueField();
655
663
  const height = this.itemHeight();
656
664
  const source = this.dataSource();
657
- if (!viewport || loading || count === 0 || values.length === 0) {
665
+ if (!viewport || loading || count === 0) {
666
+ return;
667
+ }
668
+ if (!this.#pendingSelectedScroll) {
669
+ return;
670
+ }
671
+ this.#pendingSelectedScroll = false;
672
+ if (values.length === 0) {
658
673
  return;
659
674
  }
660
675
  untracked(() => {