Skip to content

Commit 1aafdbe

Browse files
crisbetojelbourn
authored andcommitted
fix(drag-drop): disabled value not being synced to drop list ref (#15065)
Fixes the input value from the `CdkDropList` directive not being synced to the `DropListRef`.
1 parent 629460f commit 1aafdbe

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/cdk/drag-drop/directives/drag.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,25 @@ describe('CdkDrag', () => {
892892
expect(fixture.componentInstance.dropInstance.data).toBe(fixture.componentInstance.items);
893893
});
894894

895+
it('should sync the drop list inputs with the drop list ref', () => {
896+
const fixture = createComponent(DraggableInDropZone);
897+
fixture.detectChanges();
898+
899+
const dropInstance = fixture.componentInstance.dropInstance;
900+
const dropListRef = dropInstance._dropListRef;
901+
902+
expect(dropListRef.lockAxis).toBeFalsy();
903+
expect(dropListRef.disabled).toBe(false);
904+
905+
dropInstance.lockAxis = 'x';
906+
dropInstance.disabled = true;
907+
908+
dropListRef.beforeStarted.next();
909+
910+
expect(dropListRef.lockAxis).toBe('x');
911+
expect(dropListRef.disabled).toBe(true);
912+
});
913+
895914
it('should be able to attach data to a drag item', () => {
896915
const fixture = createComponent(DraggableInDropZone);
897916
fixture.detectChanges();

src/cdk/drag-drop/directives/drop-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export class CdkDropList<T = any> implements CdkDropListContainer, AfterContentI
315315
});
316316
}
317317

318+
ref.disabled = this.disabled;
318319
ref.lockAxis = this.lockAxis;
319320
ref.sortingDisabled = this.sortingDisabled;
320321
ref

0 commit comments

Comments
 (0)