Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 54f641e

Browse files
fix(cdk/drag-drop): allow axis lock to be reset (#31829)
Fixes that users weren't able to reset the `lockAxis` values. Fixes #31825.
1 parent 6ffa84a commit 54f641e

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

‎goldens/cdk/drag-drop/index.api.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
6666
getFreeDragPosition(): Readonly<Point>;
6767
getPlaceholderElement(): HTMLElement;
6868
getRootElement(): HTMLElement;
69-
lockAxis: DragAxis;
69+
lockAxis: DragAxis|null;
7070
readonly moved: Observable<CdkDragMove<T>>;
7171
// (undocumented)
7272
static ngAcceptInputType_disabled: unknown;
@@ -259,7 +259,7 @@ export class CdkDropList<T = any> implements OnDestroy {
259259
getSortedItems(): CdkDrag[];
260260
hasAnchor: boolean;
261261
id: string;
262-
lockAxis: DragAxis;
262+
lockAxis: DragAxis|null;
263263
// (undocumented)
264264
static ngAcceptInputType_autoScrollDisabled: unknown;
265265
// (undocumented)
@@ -330,7 +330,7 @@ export interface DragDropConfig extends Partial<DragRefConfig> {
330330
// (undocumented)
331331
listOrientation?: DropListOrientation;
332332
// (undocumented)
333-
lockAxis?: DragAxis;
333+
lockAxis?: DragAxis|null;
334334
// (undocumented)
335335
previewClass?: string | string[];
336336
// (undocumented)
@@ -423,7 +423,7 @@ export class DragRef<T = any> {
423423
getRootElement(): HTMLElement;
424424
getVisibleElement(): HTMLElement;
425425
isDragging(): boolean;
426-
lockAxis: 'x' | 'y';
426+
lockAxis: 'x' | 'y'|null;
427427
readonly moved: Observable<{
428428
source: DragRef;
429429
pointerPosition: {
@@ -523,7 +523,7 @@ export class DropListRef<T = any> {
523523
isDragging(): boolean;
524524
_isOverContainer(x: number, y: number): boolean;
525525
isReceiving(): boolean;
526-
lockAxis: 'x' | 'y';
526+
lockAxis: 'x' | 'y'|null;
527527
readonly receivingStarted: Subject<{
528528
receiver: DropListRef;
529529
initiator: DropListRef;

‎src/cdk/drag-drop/directives/config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const CDK_DRAG_CONFIG = new InjectionToken<DragDropConfig>('CDK_DRAG_CONF
2929
* items and drop lists within a module or a component.
3030
*/
3131
export interface DragDropConfig extends Partial<DragRefConfig> {
32-
lockAxis?: DragAxis;
32+
lockAxis?: DragAxis|null;
3333
dragStartDelay?: DragStartDelay;
3434
constrainPosition?: DragConstrainPosition;
3535
previewClass?: string | string[];

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
9191
@Input('cdkDragData') data: T;
9292

9393
/** Locks the position of the dragged element along the specified axis. */
94-
@Input('cdkDragLockAxis') lockAxis: DragAxis;
94+
@Input('cdkDragLockAxis') lockAxis: DragAxis|null=null;
9595

9696
/**
9797
* Selector that will be used to determine the root draggable element, starting from
@@ -560,10 +560,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
560560

561561
this.disabled = draggingDisabled == null ? false : draggingDisabled;
562562
this.dragStartDelay = dragStartDelay || 0;
563-
564-
if (lockAxis) {
565-
this.lockAxis = lockAxis;
566-
}
563+
this.lockAxis = lockAxis || null;
567564

568565
if (constrainPosition) {
569566
this.constrainPosition = constrainPosition;

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class CdkDropList<T = any> implements OnDestroy {
9595
@Input() id: string = inject(_IdGenerator).getId('cdk-drop-list-');
9696

9797
/** Locks the position of the draggable elements inside the container along the specified axis. */
98-
@Input('cdkDropListLockAxis') lockAxis: DragAxis;
98+
@Input('cdkDropListLockAxis') lockAxis: DragAxis|null=null;
9999

100100
/** Whether starting a dragging sequence from this container is disabled. */
101101
@Input({alias: 'cdkDropListDisabled', transform: booleanAttribute})
@@ -425,10 +425,7 @@ export class CdkDropList<T = any> implements OnDestroy {
425425
this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
426426
this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
427427
this.orientation = listOrientation || 'vertical';
428-
429-
if (lockAxis) {
430-
this.lockAxis = lockAxis;
431-
}
428+
this.lockAxis = lockAxis || null;
432429
}
433430

434431
/** Syncs up the registered drag items with underlying drop list ref. */

‎src/cdk/drag-drop/drag-ref.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export class DragRef<T = any> {
293293
private _cachedShadowRoot: ShadowRoot | null | undefined;
294294

295295
/** Axis along which dragging is locked. */
296-
lockAxis: 'x' | 'y';
296+
lockAxis: 'x' | 'y'|null=null;
297297

298298
/**
299299
* Amount of milliseconds to wait after the user has put their

‎src/cdk/drag-drop/drop-list-ref.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class DropListRef<T = any> {
6363
sortingDisabled: boolean = false;
6464

6565
/** Locks the position of the draggable elements inside the container along the specified axis. */
66-
lockAxis: 'x' | 'y';
66+
lockAxis: 'x' | 'y'|null=null;
6767

6868
/**
6969
* Whether auto-scrolling the view when the user

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /