@@ -727,6 +727,37 @@ describe('CdkDrag', () => {
727
727
expect ( styles . touchAction || ( styles as any ) . webkitUserDrag ) . toBe ( 'none' ) ;
728
728
} ) ;
729
729
730
+ it ( 'should enable native drag interactions on the drag handle if dragging is disabled' , ( ) => {
731
+ const fixture = createComponent ( StandaloneDraggableWithHandle ) ;
732
+ fixture . detectChanges ( ) ;
733
+ fixture . componentInstance . draggingDisabled = true ;
734
+ fixture . detectChanges ( ) ;
735
+ const styles = fixture . componentInstance . handleElement . nativeElement . style ;
736
+ expect ( styles . touchAction || ( styles as any ) . webkitUserDrag ) . toBeFalsy ( ) ;
737
+ } ) ;
738
+
739
+ it ( 'should enable native drag interactions on the drag handle if dragging is disabled ' +
740
+ 'on init' , ( ) => {
741
+ const fixture = createComponent ( StandaloneDraggableWithHandle ) ;
742
+ fixture . componentInstance . draggingDisabled = true ;
743
+ fixture . detectChanges ( ) ;
744
+ const styles = fixture . componentInstance . handleElement . nativeElement . style ;
745
+ expect ( styles . touchAction || ( styles as any ) . webkitUserDrag ) . toBeFalsy ( ) ;
746
+ } ) ;
747
+
748
+ it ( 'should toggle native drag interactions based on whether the handle is disabled' , ( ) => {
749
+ const fixture = createComponent ( StandaloneDraggableWithHandle ) ;
750
+ fixture . detectChanges ( ) ;
751
+ fixture . componentInstance . handleInstance . disabled = true ;
752
+ fixture . detectChanges ( ) ;
753
+ const styles = fixture . componentInstance . handleElement . nativeElement . style ;
754
+ expect ( styles . touchAction || ( styles as any ) . webkitUserDrag ) . toBeFalsy ( ) ;
755
+
756
+ fixture . componentInstance . handleInstance . disabled = false ;
757
+ fixture . detectChanges ( ) ;
758
+ expect ( styles . touchAction || ( styles as any ) . webkitUserDrag ) . toBe ( 'none' ) ;
759
+ } ) ;
760
+
730
761
it ( 'should be able to reset a freely-dragged item to its initial position' , fakeAsync ( ( ) => {
731
762
const fixture = createComponent ( StandaloneDraggable ) ;
732
763
fixture . detectChanges ( ) ;
@@ -5558,7 +5589,7 @@ class StandaloneDraggableSvgWithViewBox {
5558
5589
5559
5590
@Component ( {
5560
5591
template : `
5561
- <div #dragElement cdkDrag
5592
+ <div #dragElement cdkDrag [cdkDragDisabled]="draggingDisabled"
5562
5593
style="width: 100px; height: 100px; background: red; position: relative">
5563
5594
<div #handleElement cdkDragHandle style="width: 10px; height: 10px; background: green;"></div>
5564
5595
</div>
@@ -5569,6 +5600,7 @@ class StandaloneDraggableWithHandle {
5569
5600
@ViewChild ( 'handleElement' ) handleElement : ElementRef < HTMLElement > ;
5570
5601
@ViewChild ( CdkDrag ) dragInstance : CdkDrag ;
5571
5602
@ViewChild ( CdkDragHandle ) handleInstance : CdkDragHandle ;
5603
+ draggingDisabled = false ;
5572
5604
}
5573
5605
5574
5606
@Component ( {
0 commit comments