Skip to content

Commit b3e516f

Browse files
committed
fix(cdk/drag-drop): breaking changes for v20
Makes the breaking changes in `cdk/drag-drop` for v20. BREAKING CHANGE: * `DragDropRegistry` is no longer generic. * `DragDropRegistry.scroll` has been removed. Use the `scrolled` method instead.
1 parent 79e8872 commit b3e516f

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/cdk/drag-drop/drag-drop-registry.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ const activeCapturingEventOptions = {
5050
})
5151
export class _ResetsLoader {}
5252

53-
// TODO(crisbeto): remove generics when making breaking changes.
5453
/**
5554
* Service that keeps track of all the drag item and drop container
5655
* instances, and manages global event listeners on the `document`.
5756
* @docs-private
5857
*/
5958
@Injectable({providedIn: 'root'})
60-
export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
59+
export class DragDropRegistry implements OnDestroy {
6160
private _ngZone = inject(NgZone);
6261
private _document = inject(DOCUMENT);
6362
private _styleLoader = inject(_CdkPrivateStyleLoader);
6463
private _renderer = inject(RendererFactory2).createRenderer(null, null);
6564
private _cleanupDocumentTouchmove: (() => void) | undefined;
65+
private _scroll: Subject<Event> = new Subject<Event>();
6666

6767
/** Registered drop container instances. */
6868
private _dropInstances = new Set<DropListRef>();
@@ -101,13 +101,6 @@ export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
101101
*/
102102
readonly pointerUp: Subject<TouchEvent | MouseEvent> = new Subject<TouchEvent | MouseEvent>();
103103

104-
/**
105-
* Emits when the viewport has been scrolled while the user is dragging an item.
106-
* @deprecated To be turned into a private member. Use the `scrolled` method instead.
107-
* @breaking-change 13.0.0
108-
*/
109-
readonly scroll: Subject<Event> = new Subject<Event>();
110-
111104
constructor(...args: unknown[]);
112105
constructor() {}
113106

@@ -180,7 +173,7 @@ export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
180173
const toBind: [name: string, handler: (event: Event) => void, options: _ListenerOptions][] = [
181174
// Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
182175
// the document. See https://github.com/angular/components/issues/17144.
183-
['scroll', (e: Event) => this.scroll.next(e), capturingEventOptions],
176+
['scroll', (e: Event) => this._scroll.next(e), capturingEventOptions],
184177

185178
// Preventing the default action on `mousemove` isn't enough to disable text selection
186179
// on Safari so we need to prevent the selection event as well. Alternatively this can
@@ -245,7 +238,7 @@ export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
245238
* be used to include an additional top-level listener at the shadow root level.
246239
*/
247240
scrolled(shadowRoot?: DocumentOrShadowRoot | null): Observable<Event> {
248-
const streams: Observable<Event>[] = [this.scroll];
241+
const streams: Observable<Event>[] = [this._scroll];
249242

250243
if (shadowRoot && shadowRoot !== this._document) {
251244
// Note that this is basically the same as `fromEvent` from rxjs, but we do it ourselves,

tools/public_api_guard/cdk/drag-drop.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export class DragDropModule {
352352
}
353353

354354
// @public
355-
export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
355+
export class DragDropRegistry implements OnDestroy {
356356
constructor(...args: unknown[]);
357357
getDragDirectiveForNode(node: Node): CdkDrag | null;
358358
isDragging(drag: DragRef): boolean;
@@ -366,15 +366,13 @@ export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
366366
removeDirectiveNode(node: Node): void;
367367
removeDragItem(drag: DragRef): void;
368368
removeDropContainer(drop: DropListRef): void;
369-
// @deprecated
370-
readonly scroll: Subject<Event>;
371369
scrolled(shadowRoot?: DocumentOrShadowRoot | null): Observable<Event>;
372370
startDragging(drag: DragRef, event: TouchEvent | MouseEvent): void;
373371
stopDragging(drag: DragRef): void;
374372
// (undocumented)
375-
static ɵfac: i0.ɵɵFactoryDeclaration<DragDropRegistry<any, any>, never>;
373+
static ɵfac: i0.ɵɵFactoryDeclaration<DragDropRegistry, never>;
376374
// (undocumented)
377-
static ɵprov: i0.ɵɵInjectableDeclaration<DragDropRegistry<any, any>>;
375+
static ɵprov: i0.ɵɵInjectableDeclaration<DragDropRegistry>;
378376
}
379377

380378
// @public

0 commit comments

Comments
 (0)