@tedi-design-system/angular 7.1.0-rc.11 → 7.1.0-rc.12

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.
@@ -1559,10 +1559,15 @@ class DropdownComponent {
1559
1559
  }
1560
1560
  setupScrollListener() {
1561
1561
  this.cleanupScrollListener();
1562
- this.scrollListener = this.renderer.listen(this.document, "scroll", () => {
1563
- if (this.isOpen()) {
1564
- this.hideDropdown();
1565
- }
1562
+ this.scrollListener = this.renderer.listen(this.document, "scroll", (event) => {
1563
+ if (!this.isOpen())
1564
+ return;
1565
+ // Scrolling the dropdown panel itself must not close it
1566
+ const contentEl = this.dropdownContent().host.nativeElement;
1567
+ const target = event.target;
1568
+ if (target && contentEl.contains(target))
1569
+ return;
1570
+ this.hideDropdown();
1566
1571
  }, { capture: true, passive: true });
1567
1572
  }
1568
1573
  cleanupScrollListener() {
@@ -9252,10 +9257,14 @@ class PopoverComponent {
9252
9257
  }
9253
9258
  setupScrollListener() {
9254
9259
  this.cleanupScrollListener();
9255
- this.scrollListener = this.renderer.listen(this.document, "scroll", () => {
9256
- if (this.isOpen()) {
9257
- this.hidePopover(false);
9258
- }
9260
+ this.scrollListener = this.renderer.listen(this.document, "scroll", (event) => {
9261
+ if (!this.isOpen())
9262
+ return;
9263
+ // Scrolling content inside the popover — or inside a nested overlay
9264
+ // opened from it — must not close it
9265
+ if (this.isInsideOverlay(event.target))
9266
+ return;
9267
+ this.hidePopover(false);
9259
9268
  }, { capture: true, passive: true });
9260
9269
  }
9261
9270
  cleanupScrollListener() {
@@ -9303,20 +9312,28 @@ class PopoverComponent {
9303
9312
  setTimeout(() => previousElement.focus());
9304
9313
  }
9305
9314
  }
9315
+ /**
9316
+ * Whether the event target belongs to this popover's own overlay, or to a
9317
+ * nested overlay opened from inside it.
9318
+ *
9319
+ * Nested overlays (e.g. a month/year dropdown in the date-picker header)
9320
+ * render in their own pane within the shared CDK overlay container, not
9321
+ * inside this popover's overlayElement. Interacting with, focusing into or
9322
+ * scrolling such a child overlay must not dismiss the popover, so anything
9323
+ * inside the overlay container counts as internal.
9324
+ */
9325
+ isInsideOverlay(target) {
9326
+ if (!target)
9327
+ return false;
9328
+ const overlayEl = this.connectedOverlay()?.overlayRef?.overlayElement;
9329
+ if (overlayEl?.contains(target))
9330
+ return true;
9331
+ return (target instanceof Element && !!target.closest(".cdk-overlay-container"));
9332
+ }
9306
9333
  handleClosePopoverEvent(e) {
9307
9334
  const triggerEl = this.popoverTrigger().host.nativeElement;
9308
- const containerEl = this.connectedOverlay()?.overlayRef?.overlayElement;
9309
9335
  const target = e.target;
9310
- if (!target || triggerEl.contains(target) || containerEl?.contains(target)) {
9311
- return;
9312
- }
9313
- // Nested overlays opened from inside the popover (e.g. a month/year
9314
- // dropdown in the date-picker header) render in their own pane within the
9315
- // shared CDK overlay container, not inside this popover's overlayElement.
9316
- // Interacting with — or focusing into — such a child overlay must not
9317
- // dismiss the popover, so ignore events originating anywhere inside the
9318
- // overlay container.
9319
- if (target.closest(".cdk-overlay-container")) {
9336
+ if (!target || triggerEl.contains(target) || this.isInsideOverlay(target)) {
9320
9337
  return;
9321
9338
  }
9322
9339
  this.hidePopover(true);
@@ -11121,10 +11138,15 @@ class SelectComponent {
11121
11138
  }
11122
11139
  setupScrollListener() {
11123
11140
  this.cleanupScrollListener();
11124
- this.scrollListener = this.renderer.listen(this.document, "scroll", () => {
11125
- if (this.isOpen()) {
11126
- this.closeDropdown();
11127
- }
11141
+ this.scrollListener = this.renderer.listen(this.document, "scroll", (event) => {
11142
+ if (!this.isOpen())
11143
+ return;
11144
+ // Scrolling the option list itself must not close the dropdown
11145
+ const overlayEl = this.connectedOverlay()?.overlayRef?.overlayElement;
11146
+ const target = event.target;
11147
+ if (overlayEl && target && overlayEl.contains(target))
11148
+ return;
11149
+ this.closeDropdown();
11128
11150
  }, { capture: true, passive: true });
11129
11151
  }
11130
11152
  cleanupScrollListener() {