@angular/cdk 12.1.0-rc.0 → 12.1.3

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.
Files changed (155) hide show
  1. package/a11y/index.metadata.json +1 -1
  2. package/a11y/input-modality/input-modality-detector.d.ts +0 -2
  3. package/bundles/cdk-a11y.umd.js +11 -16
  4. package/bundles/cdk-a11y.umd.js.map +1 -1
  5. package/bundles/cdk-drag-drop.umd.js +95 -46
  6. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  7. package/bundles/cdk-overlay.umd.js +6 -6
  8. package/bundles/cdk-overlay.umd.js.map +1 -1
  9. package/bundles/cdk-platform.umd.js +7 -0
  10. package/bundles/cdk-platform.umd.js.map +1 -1
  11. package/bundles/cdk-portal.umd.js.map +1 -1
  12. package/bundles/cdk-scrolling.umd.js +3 -3
  13. package/bundles/cdk-scrolling.umd.js.map +1 -1
  14. package/bundles/cdk-stepper.umd.js +11 -7
  15. package/bundles/cdk-stepper.umd.js.map +1 -1
  16. package/bundles/cdk-table.umd.js +25 -9
  17. package/bundles/cdk-table.umd.js.map +1 -1
  18. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  19. package/bundles/cdk-testing-selenium-webdriver.umd.js.map +1 -1
  20. package/bundles/cdk-testing-testbed.umd.js +4 -2
  21. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  22. package/bundles/cdk-testing.umd.js.map +1 -1
  23. package/bundles/cdk-tree.umd.js +3 -5
  24. package/bundles/cdk-tree.umd.js.map +1 -1
  25. package/bundles/cdk.umd.js +1 -1
  26. package/bundles/cdk.umd.js.map +1 -1
  27. package/drag-drop/drag-drop-registry.d.ts +14 -2
  28. package/drag-drop/drag-styling.d.ts +5 -10
  29. package/drag-drop/index.metadata.json +1 -1
  30. package/esm2015/a11y/fake-event-detection.js +7 -6
  31. package/esm2015/a11y/focus-monitor/focus-monitor.js +5 -5
  32. package/esm2015/a11y/focus-trap/configurable-focus-trap.js +1 -1
  33. package/esm2015/a11y/input-modality/input-modality-detector.js +5 -11
  34. package/esm2015/a11y/key-manager/activedescendant-key-manager.js +1 -1
  35. package/esm2015/a11y/key-manager/focus-key-manager.js +1 -1
  36. package/esm2015/drag-drop/drag-drop-registry.js +37 -3
  37. package/esm2015/drag-drop/drag-ref.js +29 -19
  38. package/esm2015/drag-drop/drag-styling.js +26 -16
  39. package/esm2015/drag-drop/drop-list-ref.js +4 -2
  40. package/esm2015/drag-drop/parent-position-tracker.js +3 -2
  41. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +1 -1
  42. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +3 -4
  43. package/esm2015/overlay/fullscreen-overlay-container.js +1 -1
  44. package/esm2015/overlay/overlay-container.js +6 -5
  45. package/esm2015/platform/features/shadow-dom.js +7 -1
  46. package/esm2015/portal/dom-portal-outlet.js +1 -1
  47. package/esm2015/portal/portal-directives.js +1 -1
  48. package/esm2015/portal/portal.js +1 -1
  49. package/esm2015/scrolling/viewport-ruler.js +4 -4
  50. package/esm2015/scrolling/virtual-scroll-viewport.js +1 -1
  51. package/esm2015/stepper/stepper.js +9 -4
  52. package/esm2015/table/cell.js +16 -4
  53. package/esm2015/table/row.js +1 -1
  54. package/esm2015/table/table.js +2 -2
  55. package/esm2015/testing/protractor/protractor-element.js +1 -1
  56. package/esm2015/testing/selenium-webdriver/selenium-web-driver-element.js +1 -1
  57. package/esm2015/testing/test-element.js +1 -1
  58. package/esm2015/testing/testbed/fake-events/event-objects.js +5 -3
  59. package/esm2015/testing/testbed/unit-test-element.js +1 -1
  60. package/esm2015/tree/control/flat-tree-control.js +1 -1
  61. package/esm2015/tree/control/nested-tree-control.js +1 -1
  62. package/esm2015/tree/nested-node.js +4 -6
  63. package/esm2015/version.js +1 -1
  64. package/fesm2015/a11y.js +12 -17
  65. package/fesm2015/a11y.js.map +1 -1
  66. package/fesm2015/cdk.js +1 -1
  67. package/fesm2015/cdk.js.map +1 -1
  68. package/fesm2015/drag-drop.js +92 -36
  69. package/fesm2015/drag-drop.js.map +1 -1
  70. package/fesm2015/overlay.js +7 -7
  71. package/fesm2015/overlay.js.map +1 -1
  72. package/fesm2015/platform.js +7 -1
  73. package/fesm2015/platform.js.map +1 -1
  74. package/fesm2015/portal.js.map +1 -1
  75. package/fesm2015/scrolling.js +3 -3
  76. package/fesm2015/scrolling.js.map +1 -1
  77. package/fesm2015/stepper.js +8 -3
  78. package/fesm2015/stepper.js.map +1 -1
  79. package/fesm2015/table.js +15 -3
  80. package/fesm2015/table.js.map +1 -1
  81. package/fesm2015/testing/protractor.js.map +1 -1
  82. package/fesm2015/testing/selenium-webdriver.js.map +1 -1
  83. package/fesm2015/testing/testbed.js +4 -2
  84. package/fesm2015/testing/testbed.js.map +1 -1
  85. package/fesm2015/testing.js.map +1 -1
  86. package/fesm2015/tree.js +3 -5
  87. package/fesm2015/tree.js.map +1 -1
  88. package/overlay/index.metadata.json +1 -1
  89. package/package.json +1 -1
  90. package/platform/features/shadow-dom.d.ts +2 -0
  91. package/platform/index.metadata.json +1 -1
  92. package/schematics/ng-add/index.js +1 -1
  93. package/schematics/ng-add/index.mjs +1 -1
  94. package/schematics/ng-add/package-config.js +5 -2
  95. package/schematics/ng-add/package-config.mjs +5 -2
  96. package/schematics/ng-update/devkit-migration-rule.js +1 -1
  97. package/schematics/ng-update/devkit-migration-rule.mjs +1 -1
  98. package/schematics/ng-update/find-stylesheets.js +2 -2
  99. package/schematics/ng-update/find-stylesheets.mjs +2 -2
  100. package/schematics/ng-update/html-parsing/elements.d.ts +2 -1
  101. package/schematics/ng-update/html-parsing/elements.js +6 -4
  102. package/schematics/ng-update/html-parsing/elements.mjs +6 -4
  103. package/schematics/ng-update/migrations/attribute-selectors.d.ts +3 -2
  104. package/schematics/ng-update/migrations/attribute-selectors.js +1 -1
  105. package/schematics/ng-update/migrations/attribute-selectors.mjs +1 -1
  106. package/schematics/ng-update/migrations/class-inheritance.js +1 -1
  107. package/schematics/ng-update/migrations/class-inheritance.mjs +1 -1
  108. package/schematics/ng-update/migrations/class-names.js +1 -1
  109. package/schematics/ng-update/migrations/class-names.mjs +1 -1
  110. package/schematics/ng-update/migrations/constructor-signature.js +1 -1
  111. package/schematics/ng-update/migrations/constructor-signature.mjs +1 -1
  112. package/schematics/ng-update/migrations/css-selectors.js +1 -1
  113. package/schematics/ng-update/migrations/css-selectors.mjs +1 -1
  114. package/schematics/ng-update/migrations/element-selectors.d.ts +3 -2
  115. package/schematics/ng-update/migrations/element-selectors.js +1 -1
  116. package/schematics/ng-update/migrations/element-selectors.mjs +1 -1
  117. package/schematics/ng-update/migrations/input-names.js +1 -1
  118. package/schematics/ng-update/migrations/input-names.mjs +1 -1
  119. package/schematics/ng-update/migrations/method-call-arguments.js +1 -1
  120. package/schematics/ng-update/migrations/method-call-arguments.mjs +1 -1
  121. package/schematics/ng-update/migrations/misc-template.js +1 -1
  122. package/schematics/ng-update/migrations/misc-template.mjs +1 -1
  123. package/schematics/ng-update/migrations/output-names.js +1 -1
  124. package/schematics/ng-update/migrations/output-names.mjs +1 -1
  125. package/schematics/ng-update/migrations/property-names.js +1 -1
  126. package/schematics/ng-update/migrations/property-names.mjs +1 -1
  127. package/schematics/ng-update/typescript/base-types.js +2 -2
  128. package/schematics/ng-update/typescript/base-types.mjs +2 -2
  129. package/schematics/tsconfig.json +6 -0
  130. package/schematics/update-tool/migration.d.ts +2 -2
  131. package/schematics/update-tool/migration.js +1 -1
  132. package/schematics/update-tool/migration.mjs +1 -1
  133. package/schematics/utils/build-component.js +7 -4
  134. package/schematics/utils/build-component.mjs +7 -4
  135. package/schematics/utils/html-manipulation.d.ts +2 -2
  136. package/schematics/utils/html-manipulation.js +1 -1
  137. package/schematics/utils/html-manipulation.mjs +1 -1
  138. package/schematics/utils/parse5-element.d.ts +2 -2
  139. package/schematics/utils/parse5-element.js +2 -2
  140. package/schematics/utils/parse5-element.mjs +2 -2
  141. package/schematics/utils/schematic-options.d.ts +2 -6
  142. package/schematics/utils/schematic-options.js +3 -2
  143. package/schematics/utils/schematic-options.mjs +3 -2
  144. package/schematics/utils/vendored-ast-utils/index.js +8 -7
  145. package/schematics/utils/vendored-ast-utils/index.mjs +8 -7
  146. package/scrolling/index.metadata.json +1 -1
  147. package/stepper/index.metadata.json +1 -1
  148. package/stepper/stepper.d.ts +6 -2
  149. package/table/index.metadata.json +1 -1
  150. package/testing/protractor/protractor-element.d.ts +1 -1
  151. package/testing/selenium-webdriver/selenium-web-driver-element.d.ts +1 -1
  152. package/testing/test-element.d.ts +1 -1
  153. package/testing/testbed/unit-test-element.d.ts +1 -1
  154. package/tree/index.metadata.json +1 -1
  155. package/tree/nested-node.d.ts +1 -3
package/fesm2015/cdk.js CHANGED
@@ -8,7 +8,7 @@ import { Version } from '@angular/core';
8
8
  * found in the LICENSE file at https://angular.io/license
9
9
  */
10
10
  /** Current version of the Angular Component Development Kit. */
11
- const VERSION = new Version('12.1.0-rc.0');
11
+ const VERSION = new Version('12.1.3');
12
12
 
13
13
  /**
14
14
  * @license
@@ -1 +1 @@
1
- {"version":3,"file":"cdk.js","sources":["../../../../../../src/cdk/version.ts","../../../../../../src/cdk/public-api.ts","../../../../../../src/cdk/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('12.1.0-rc.0');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './version';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;ACXtD;;;;;;;;ACAA;;;;;;;;;;"}
1
+ {"version":3,"file":"cdk.js","sources":["../../../../../../src/cdk/version.ts","../../../../../../src/cdk/public-api.ts","../../../../../../src/cdk/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('12.1.3');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './version';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;;AAUA;MACa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;ACXtD;;;;;;;;ACAA;;;;;;;;;;"}
@@ -4,8 +4,9 @@ import * as i1 from '@angular/common';
4
4
  import { DOCUMENT } from '@angular/common';
5
5
  import * as i2 from '@angular/cdk/scrolling';
6
6
  import { ViewportRuler, ScrollDispatcher, CdkScrollableModule } from '@angular/cdk/scrolling';
7
- import { normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
7
+ import { _getEventTarget, normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
8
8
  import { coerceBooleanProperty, coerceElement, coerceArray, coerceNumberProperty } from '@angular/cdk/coercion';
9
+ import { isFakeTouchstartFromScreenReader, isFakeMousedownFromScreenReader } from '@angular/cdk/a11y';
9
10
  import { Subject, Subscription, interval, animationFrameScheduler, Observable, merge } from 'rxjs';
10
11
  import { takeUntil, startWith, map, take, tap, switchMap } from 'rxjs/operators';
11
12
  import { Directionality } from '@angular/cdk/bidi';
@@ -18,13 +19,20 @@ import { Directionality } from '@angular/cdk/bidi';
18
19
  * found in the LICENSE file at https://angular.io/license
19
20
  */
20
21
  /**
21
- * Shallow-extends a stylesheet object with another stylesheet object.
22
+ * Shallow-extends a stylesheet object with another stylesheet-like object.
23
+ * Note that the keys in `source` have to be dash-cased.
22
24
  * @docs-private
23
25
  */
24
- function extendStyles(dest, source) {
26
+ function extendStyles(dest, source, importantProperties) {
25
27
  for (let key in source) {
26
28
  if (source.hasOwnProperty(key)) {
27
- dest[key] = source[key];
29
+ const value = source[key];
30
+ if (value) {
31
+ dest.setProperty(key, value, (importantProperties === null || importantProperties === void 0 ? void 0 : importantProperties.has(key)) ? 'important' : '');
32
+ }
33
+ else {
34
+ dest.removeProperty(key);
35
+ }
28
36
  }
29
37
  }
30
38
  return dest;
@@ -38,26 +46,29 @@ function extendStyles(dest, source) {
38
46
  function toggleNativeDragInteractions(element, enable) {
39
47
  const userSelect = enable ? '' : 'none';
40
48
  extendStyles(element.style, {
41
- touchAction: enable ? '' : 'none',
42
- webkitUserDrag: enable ? '' : 'none',
43
- webkitTapHighlightColor: enable ? '' : 'transparent',
44
- userSelect: userSelect,
45
- msUserSelect: userSelect,
46
- webkitUserSelect: userSelect,
47
- MozUserSelect: userSelect
49
+ 'touch-action': enable ? '' : 'none',
50
+ '-webkit-user-drag': enable ? '' : 'none',
51
+ '-webkit-tap-highlight-color': enable ? '' : 'transparent',
52
+ 'user-select': userSelect,
53
+ '-ms-user-select': userSelect,
54
+ '-webkit-user-select': userSelect,
55
+ '-moz-user-select': userSelect
48
56
  });
49
57
  }
50
58
  /**
51
59
  * Toggles whether an element is visible while preserving its dimensions.
52
60
  * @param element Element whose visibility to toggle
53
61
  * @param enable Whether the element should be visible.
62
+ * @param importantProperties Properties to be set as `!important`.
54
63
  * @docs-private
55
64
  */
56
- function toggleVisibility(element, enable) {
57
- const styles = element.style;
58
- styles.position = enable ? '' : 'fixed';
59
- styles.top = styles.opacity = enable ? '' : '0';
60
- styles.left = enable ? '' : '-999em';
65
+ function toggleVisibility(element, enable, importantProperties) {
66
+ extendStyles(element.style, {
67
+ position: enable ? '' : 'fixed',
68
+ top: enable ? '' : '0',
69
+ opacity: enable ? '' : '0',
70
+ left: enable ? '' : '-999em'
71
+ }, importantProperties);
61
72
  }
62
73
  /**
63
74
  * Combines a transform string with an optional other transform
@@ -197,7 +208,7 @@ class ParentPositionTracker {
197
208
  }
198
209
  /** Handles scrolling while a drag is taking place. */
199
210
  handleScroll(event) {
200
- const target = event.target;
211
+ const target = _getEventTarget(event);
201
212
  const cachedPosition = this.positions.get(target);
202
213
  if (!cachedPosition) {
203
214
  return null;
@@ -316,6 +327,11 @@ const activeEventListenerOptions = normalizePassiveListenerOptions({ passive: fa
316
327
  * addition to touch events.
317
328
  */
318
329
  const MOUSE_EVENT_IGNORE_TIME = 800;
330
+ /** Inline styles to be set as `!important` while dragging. */
331
+ const dragImportantProperties = new Set([
332
+ // Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781.
333
+ 'position'
334
+ ]);
319
335
  /**
320
336
  * Reference to a draggable item. Used to manipulate or dispose of the item.
321
337
  */
@@ -391,7 +407,7 @@ class DragRef {
391
407
  // Delegate the event based on whether it started from a handle or the element itself.
392
408
  if (this._handles.length) {
393
409
  const targetHandle = this._handles.find(handle => {
394
- const target = event.target;
410
+ const target = _getEventTarget(event);
395
411
  return !!target && (target === handle || handle.contains(target));
396
412
  });
397
413
  if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {
@@ -798,7 +814,7 @@ class DragRef {
798
814
  // We move the element out at the end of the body and we make it hidden, because keeping it in
799
815
  // place will throw off the consumer's `:last-child` selectors. We can't remove the element
800
816
  // from the DOM completely, because iOS will stop firing all subsequent events in the chain.
801
- toggleVisibility(element, false);
817
+ toggleVisibility(element, false, dragImportantProperties);
802
818
  this._document.body.appendChild(parent.replaceChild(placeholder, element));
803
819
  this._getPreviewInsertionPoint(parent, shadowRoot).appendChild(this._preview);
804
820
  this.started.next({ source: this }); // Emit before notifying the container.
@@ -830,19 +846,22 @@ class DragRef {
830
846
  const isTouchSequence = isTouchEvent(event);
831
847
  const isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
832
848
  const rootElement = this._rootElement;
849
+ const target = _getEventTarget(event);
833
850
  const isSyntheticEvent = !isTouchSequence && this._lastTouchEventTime &&
834
851
  this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
852
+ const isFakeEvent = isTouchSequence ? isFakeTouchstartFromScreenReader(event) :
853
+ isFakeMousedownFromScreenReader(event);
835
854
  // If the event started from an element with the native HTML drag&drop, it'll interfere
836
855
  // with our own dragging (e.g. `img` tags do it by default). Prevent the default action
837
856
  // to stop it from happening. Note that preventing on `dragstart` also seems to work, but
838
857
  // it's flaky and it fails if the user drags it away quickly. Also note that we only want
839
858
  // to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
840
859
  // events from firing on touch devices.
841
- if (event.target && event.target.draggable && event.type === 'mousedown') {
860
+ if (target && target.draggable && event.type === 'mousedown') {
842
861
  event.preventDefault();
843
862
  }
844
863
  // Abort if the user is already dragging or is using a mouse button other than the primary one.
845
- if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent) {
864
+ if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent || isFakeEvent) {
846
865
  return;
847
866
  }
848
867
  // If we've got handles, we need to disable the tap highlight on the entire root element,
@@ -858,9 +877,9 @@ class DragRef {
858
877
  this._removeSubscriptions();
859
878
  this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
860
879
  this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
861
- this._scrollSubscription = this._dragDropRegistry.scroll.subscribe(scrollEvent => {
862
- this._updateOnScroll(scrollEvent);
863
- });
880
+ this._scrollSubscription = this._dragDropRegistry
881
+ .scrolled(this._getShadowRoot())
882
+ .subscribe(scrollEvent => this._updateOnScroll(scrollEvent));
864
883
  if (this._boundaryElement) {
865
884
  this._boundaryRect = getMutableClientRect(this._boundaryElement);
866
885
  }
@@ -884,7 +903,7 @@ class DragRef {
884
903
  // It's important that we maintain the position, because moving the element around in the DOM
885
904
  // can throw off `NgFor` which does smart diffing and re-creates elements only when necessary,
886
905
  // while moving the existing elements in all other cases.
887
- toggleVisibility(this._rootElement, true);
906
+ toggleVisibility(this._rootElement, true, dragImportantProperties);
888
907
  this._anchor.parentNode.replaceChild(this._rootElement, this._anchor);
889
908
  this._destroyPreview();
890
909
  this._destroyPlaceholder();
@@ -987,14 +1006,14 @@ class DragRef {
987
1006
  extendStyles(preview.style, {
988
1007
  // It's important that we disable the pointer events on the preview, because
989
1008
  // it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
990
- pointerEvents: 'none',
1009
+ 'pointer-events': 'none',
991
1010
  // We have to reset the margin, because it can throw off positioning relative to the viewport.
992
- margin: '0',
993
- position: 'fixed',
994
- top: '0',
995
- left: '0',
996
- zIndex: `${this._config.zIndex || 1000}`
997
- });
1011
+ 'margin': '0',
1012
+ 'position': 'fixed',
1013
+ 'top': '0',
1014
+ 'left': '0',
1015
+ 'z-index': `${this._config.zIndex || 1000}`
1016
+ }, dragImportantProperties);
998
1017
  toggleNativeDragInteractions(preview, false);
999
1018
  preview.classList.add('cdk-drag-preview');
1000
1019
  preview.setAttribute('dir', this._direction);
@@ -1033,7 +1052,8 @@ class DragRef {
1033
1052
  return this._ngZone.runOutsideAngular(() => {
1034
1053
  return new Promise(resolve => {
1035
1054
  const handler = ((event) => {
1036
- if (!event || (event.target === this._preview && event.propertyName === 'transform')) {
1055
+ if (!event || (_getEventTarget(event) === this._preview &&
1056
+ event.propertyName === 'transform')) {
1037
1057
  this._preview.removeEventListener('transitionend', handler);
1038
1058
  resolve();
1039
1059
  clearTimeout(timeout);
@@ -1281,7 +1301,7 @@ class DragRef {
1281
1301
  _updateOnScroll(event) {
1282
1302
  const scrollDifference = this._parentPositions.handleScroll(event);
1283
1303
  if (scrollDifference) {
1284
- const target = event.target;
1304
+ const target = _getEventTarget(event);
1285
1305
  // ClientRect dimensions are based on the scroll position of the page and its parent node so
1286
1306
  // we have to update the cached boundary ClientRect if the user has scrolled. Check for
1287
1307
  // the `document` specifically since IE doesn't support `contains` on it.
@@ -2137,7 +2157,9 @@ class DropListRef {
2137
2157
  * Used for updating the internal state of the list.
2138
2158
  */
2139
2159
  _listenToScrollEvents() {
2140
- this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe(event => {
2160
+ this._viewportScrollSubscription = this._dragDropRegistry
2161
+ .scrolled(this._getShadowRoot())
2162
+ .subscribe(event => {
2141
2163
  if (this.isDragging()) {
2142
2164
  const scrollDifference = this._parentPositions.handleScroll(event);
2143
2165
  if (scrollDifference) {
@@ -2345,7 +2367,11 @@ class DragDropRegistry {
2345
2367
  * while the user is dragging a drag item instance.
2346
2368
  */
2347
2369
  this.pointerUp = new Subject();
2348
- /** Emits when the viewport has been scrolled while the user is dragging an item. */
2370
+ /**
2371
+ * Emits when the viewport has been scrolled while the user is dragging an item.
2372
+ * @deprecated To be turned into a private member. Use the `scrolled` method instead.
2373
+ * @breaking-change 13.0.0
2374
+ */
2349
2375
  this.scroll = new Subject();
2350
2376
  /**
2351
2377
  * Event listener that will prevent the default browser action while the user is dragging.
@@ -2466,6 +2492,36 @@ class DragDropRegistry {
2466
2492
  isDragging(drag) {
2467
2493
  return this._activeDragInstances.indexOf(drag) > -1;
2468
2494
  }
2495
+ /**
2496
+ * Gets a stream that will emit when any element on the page is scrolled while an item is being
2497
+ * dragged.
2498
+ * @param shadowRoot Optional shadow root that the current dragging sequence started from.
2499
+ * Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
2500
+ * be used to include an additional top-level listener at the shadow root level.
2501
+ */
2502
+ scrolled(shadowRoot) {
2503
+ const streams = [this.scroll];
2504
+ if (shadowRoot && shadowRoot !== this._document) {
2505
+ // Note that this is basically the same as `fromEvent` from rjxs, but we do it ourselves,
2506
+ // because we want to guarantee that the event is bound outside of the `NgZone`. With
2507
+ // `fromEvent` it'll only happen if the subscription is outside the `NgZone`.
2508
+ streams.push(new Observable((observer) => {
2509
+ return this._ngZone.runOutsideAngular(() => {
2510
+ const eventOptions = true;
2511
+ const callback = (event) => {
2512
+ if (this._activeDragInstances.length) {
2513
+ observer.next(event);
2514
+ }
2515
+ };
2516
+ shadowRoot.addEventListener('scroll', callback, eventOptions);
2517
+ return () => {
2518
+ shadowRoot.removeEventListener('scroll', callback, eventOptions);
2519
+ };
2520
+ });
2521
+ }));
2522
+ }
2523
+ return merge(...streams);
2524
+ }
2469
2525
  ngOnDestroy() {
2470
2526
  this._dragInstances.forEach(instance => this.removeDragItem(instance));
2471
2527
  this._dropInstances.forEach(instance => this.removeDropContainer(instance));