@mozaic-ds/angular 2.0.17 → 2.0.18

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.
@@ -10613,6 +10613,8 @@ class MozComboboxComponent {
10613
10613
  searchQuery = signal('', ...(ngDevMode ? [{ debugName: "searchQuery" }] : []));
10614
10614
  /** Disabled state from ControlValueAccessor */
10615
10615
  _disabledFromForm = signal(false, ...(ngDevMode ? [{ debugName: "_disabledFromForm" }] : []));
10616
+ /** Cache of value → label for all options ever seen (survives items changes) */
10617
+ _labelCache = new Map();
10616
10618
  /** CVA callbacks */
10617
10619
  _onChange = () => { };
10618
10620
  _onTouched = () => { };
@@ -10691,13 +10693,12 @@ class MozComboboxComponent {
10691
10693
  const flat = this.flatItems();
10692
10694
  const options = flat.filter(isFlatOption);
10693
10695
  const cmp = this.compareWith();
10696
+ const cache = this._labelCache;
10697
+ const findLabel = (v) => options.find((o) => cmp(o.value, v))?.label ?? cache.get(v) ?? '';
10694
10698
  if (Array.isArray(val)) {
10695
- return val
10696
- .map((v) => options.find((o) => cmp(o.value, v))?.label ?? '')
10697
- .filter(Boolean)
10698
- .join(', ');
10699
+ return val.map(findLabel).filter(Boolean).join(', ');
10699
10700
  }
10700
- return options.find((o) => cmp(o.value, val))?.label ?? '';
10701
+ return findLabel(val);
10701
10702
  }, ...(ngDevMode ? [{ debugName: "displayValue" }] : []));
10702
10703
  /** Number of selected items (for compact counter) */
10703
10704
  selectedCount = computed(() => {
@@ -10773,6 +10774,15 @@ class MozComboboxComponent {
10773
10774
  const val = this.value();
10774
10775
  this._onChange(val);
10775
10776
  });
10777
+ // Keep the label cache up to date whenever items change
10778
+ effect(() => {
10779
+ const flat = this.flatItems();
10780
+ for (const item of flat) {
10781
+ if (isFlatOption(item)) {
10782
+ this._labelCache.set(item.value, item.label);
10783
+ }
10784
+ }
10785
+ });
10776
10786
  // Inject global overlay styles — CDK teleports content outside the
10777
10787
  // component host so scoped CSS never reaches .cdk-overlay-pane.
10778
10788
  // Check DOM each render — Storybook may remove the tag on navigation.