@besaitech/ng-design-system 0.0.79 → 0.0.80

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.
@@ -12450,6 +12450,15 @@ class SdsAutocomplete {
12450
12450
  cvaDisabled = signal(false, ...(ngDevMode ? [{ debugName: "cvaDisabled" }] : []));
12451
12451
  /** Every option this control has seen, by value — how a chip keeps its label after a new search. */
12452
12452
  seen = new Map();
12453
+ /**
12454
+ * A plain reference to the body-appended panel, not just the viewChild.
12455
+ *
12456
+ * <p>On destroy the viewChild is already cleared — it lives inside an `@if` — so removing through
12457
+ * it removes nothing and the panel is orphaned in `<body>` for ever. A test caught it: a leaked
12458
+ * panel from one spec was still in the document when the next one queried for its own.
12459
+ * `sds-select` keeps the same raw handle, for the same reason.
12460
+ */
12461
+ panelEl = null;
12453
12462
  timer;
12454
12463
  seq = 0;
12455
12464
  destroyed = false;
@@ -12598,8 +12607,9 @@ class SdsAutocomplete {
12598
12607
  event?.stopPropagation();
12599
12608
  if (this.isOptionDisabled(option))
12600
12609
  return;
12610
+ // No need to remember it here: `run` already stored every row it returned, and an option can
12611
+ // only be picked from those. (A mutation check proved this line unreachable.)
12601
12612
  const v = this.valueOf(option);
12602
- this.seen.set(v, option);
12603
12613
  if (!this.multiple()) {
12604
12614
  this.setValue(v);
12605
12615
  this.selected.emit(option);
@@ -12673,15 +12683,15 @@ class SdsAutocomplete {
12673
12683
  this.open.set(false);
12674
12684
  this.active.set(-1);
12675
12685
  this.removeReflow();
12676
- this.panelRef()?.nativeElement.remove();
12686
+ this.panelEl?.remove();
12687
+ this.panelEl = null;
12677
12688
  this.closed.emit(this.value());
12678
12689
  }
12679
12690
  onDocumentClick(event) {
12680
12691
  if (!this.open())
12681
12692
  return;
12682
12693
  const target = event.target;
12683
- const panel = this.panelRef()?.nativeElement;
12684
- if (!this.host.nativeElement.contains(target) && !panel?.contains(target)) {
12694
+ if (!this.host.nativeElement.contains(target) && !this.panelEl?.contains(target)) {
12685
12695
  this.close();
12686
12696
  }
12687
12697
  }
@@ -12707,6 +12717,7 @@ class SdsAutocomplete {
12707
12717
  const panel = this.panelRef()?.nativeElement;
12708
12718
  if (!trigger || !panel)
12709
12719
  return;
12720
+ this.panelEl = panel;
12710
12721
  if (panel.parentElement !== document.body)
12711
12722
  document.body.appendChild(panel);
12712
12723
  const r = trigger.getBoundingClientRect();
@@ -12730,7 +12741,8 @@ class SdsAutocomplete {
12730
12741
  this.destroyed = true;
12731
12742
  clearTimeout(this.timer);
12732
12743
  this.removeReflow();
12733
- this.panelRef()?.nativeElement.remove();
12744
+ this.panelEl?.remove();
12745
+ this.panelEl = null;
12734
12746
  }
12735
12747
  setValue(v) {
12736
12748
  this.value.set(v);
@@ -12835,6 +12847,7 @@ class SdsAutocomplete {
12835
12847
  #panel
12836
12848
  [id]="panelId"
12837
12849
  role="listbox"
12850
+ data-sds-autocomplete-panel
12838
12851
  [attr.aria-multiselectable]="multiple() ? 'true' : null"
12839
12852
  class="fixed z-50 max-h-72 overflow-auto rounded-control border border-border bg-surface py-1 shadow-lg"
12840
12853
  >
@@ -13008,6 +13021,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
13008
13021
  #panel
13009
13022
  [id]="panelId"
13010
13023
  role="listbox"
13024
+ data-sds-autocomplete-panel
13011
13025
  [attr.aria-multiselectable]="multiple() ? 'true' : null"
13012
13026
  class="fixed z-50 max-h-72 overflow-auto rounded-control border border-border bg-surface py-1 shadow-lg"
13013
13027
  >