cps-ui-kit 21.29.0 → 21.29.2

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.
@@ -2824,7 +2824,7 @@ class CpsAutocompleteComponent {
2824
2824
  selected.scrollIntoView({
2825
2825
  behavior: 'instant',
2826
2826
  block: 'nearest',
2827
- inline: 'center'
2827
+ inline: 'start'
2828
2828
  });
2829
2829
  }
2830
2830
  else if (this.virtualScroll && this.optionHighlightedIndex >= 0) {
@@ -2915,7 +2915,7 @@ class CpsAutocompleteComponent {
2915
2915
  if (elRect.top < parentRect.top || elRect.bottom > parentRect.bottom) {
2916
2916
  el.scrollIntoView({
2917
2917
  block: 'nearest',
2918
- inline: 'center'
2918
+ inline: 'nearest'
2919
2919
  });
2920
2920
  }
2921
2921
  }
@@ -6075,7 +6075,7 @@ class CpsSelectComponent {
6075
6075
  selected.scrollIntoView({
6076
6076
  behavior: 'instant',
6077
6077
  block: 'nearest',
6078
- inline: 'center'
6078
+ inline: 'start'
6079
6079
  });
6080
6080
  }
6081
6081
  else if (this.virtualScroll && this.optionHighlightedIndex >= 0) {
@@ -6166,7 +6166,7 @@ class CpsSelectComponent {
6166
6166
  if (elRect.top < parentRect.top || elRect.bottom > parentRect.bottom) {
6167
6167
  el.scrollIntoView({
6168
6168
  block: 'nearest',
6169
- inline: 'center'
6169
+ inline: 'nearest'
6170
6170
  });
6171
6171
  }
6172
6172
  }
@@ -13772,29 +13772,31 @@ class CpsBaseTreeDropdownComponent {
13772
13772
  setTimeout(() => {
13773
13773
  this.updateOptions();
13774
13774
  this.recalcVirtualListHeight();
13775
- const selected = this.treeContainerElement?.querySelector('.p-highlight');
13776
- if (selected) {
13777
- selected.scrollIntoView({
13778
- behavior: 'instant',
13779
- block: 'nearest',
13780
- inline: 'center'
13781
- });
13782
- }
13783
- else if (this.virtualScroll && this.treeSelection) {
13784
- let key = '';
13775
+ let key = '';
13776
+ if (this.treeSelection) {
13785
13777
  if (this.multiple) {
13786
13778
  if (this.treeSelection.length > 0)
13787
13779
  key = this.treeSelection[0].key;
13788
13780
  }
13789
13781
  else
13790
13782
  key = this.treeSelection.key;
13791
- if (key) {
13792
- const idx = this.treeList?.serializedValue?.findIndex(
13793
- // https://github.com/primefaces/primeng/blob/v16.4.3/src/app/components/tree/tree.ts#L1125
13794
- (v) => v.node.key === key) || -1;
13795
- if (idx >= 0)
13796
- this.treeList.scrollToVirtualIndex(idx);
13797
- }
13783
+ }
13784
+ const selected = key
13785
+ ? this.treeContainerElement?.querySelector(`.key-${key}`)
13786
+ : null;
13787
+ if (selected) {
13788
+ selected.scrollIntoView({
13789
+ behavior: 'instant',
13790
+ block: 'nearest',
13791
+ inline: 'start'
13792
+ });
13793
+ }
13794
+ else if (this.virtualScroll && key) {
13795
+ const idx = this.treeList?.serializedValue?.findIndex(
13796
+ // https://github.com/primefaces/primeng/blob/v16.4.3/src/app/components/tree/tree.ts#L1125
13797
+ (v) => v.node.key === key) ?? -1;
13798
+ if (idx >= 0)
13799
+ this.treeList.scrollToVirtualIndex(idx);
13798
13800
  }
13799
13801
  });
13800
13802
  }
@@ -13936,6 +13938,10 @@ class CpsBaseTreeDropdownComponent {
13936
13938
  if (!this.virtualScroll)
13937
13939
  return;
13938
13940
  this.treeList?.updateSerializedValue();
13941
+ // treeList is OnPush and serializedValue is a plain field, so its new
13942
+ // value won't reach the scroller's items input until treeList's own
13943
+ // view is force-checked
13944
+ this.treeList?.cd?.detectChanges();
13939
13945
  }
13940
13946
  _initContainerClickListener() {
13941
13947
  this.treeContainerElement = this.treeList?.el?.nativeElement?.querySelector('.p-tree-root-children');