@@ -30,7 +30,7 @@ import {
30
30
} from '@angular/core' ;
31
31
import { normalizePassiveListenerOptions } from '@angular/cdk/platform' ;
32
32
import { Observable , Subject , Subscription , Observer } from 'rxjs' ;
33
- import { take } from 'rxjs/operators' ;
33
+ import { startWith , take } from 'rxjs/operators' ;
34
34
import { DragDropRegistry } from './drag-drop-registry' ;
35
35
import {
36
36
CdkDragDrop ,
@@ -274,7 +274,8 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
274
274
const rootElement = this . _rootElement = this . _getRootElement ( ) ;
275
275
rootElement . addEventListener ( 'mousedown' , this . _pointerDown , passiveEventListenerOptions ) ;
276
276
rootElement . addEventListener ( 'touchstart' , this . _pointerDown , passiveEventListenerOptions ) ;
277
- toggleNativeDragInteractions ( rootElement , false ) ;
277
+ this . _handles . changes . pipe ( startWith ( null ) ) . subscribe ( ( ) =>
278
+ toggleNativeDragInteractions ( rootElement , this . getChildHandles ( ) . length > 0 ) ) ;
278
279
} ) ;
279
280
}
280
281
@@ -309,10 +310,14 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
309
310
return this . _dragDropRegistry . isDragging ( this ) ;
310
311
}
311
312
313
+ /** Gets only handles that are not inside descendant `CdkDrag` instances. */
314
+ private getChildHandles ( ) {
315
+ return this . _handles . filter ( handle => handle . _parentDrag === this ) ;
316
+ }
317
+
312
318
/** Handler for the `mousedown`/`touchstart` events. */
313
319
_pointerDown = ( event : MouseEvent | TouchEvent ) => {
314
- // Skip handles inside descendant `CdkDrag` instances.
315
- const handles = this . _handles . filter ( handle => handle . _parentDrag === this ) ;
320
+ const handles = this . getChildHandles ( ) ;
316
321
317
322
// Delegate the event based on whether it started from a handle or the element itself.
318
323
if ( handles . length ) {
0 commit comments