-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(cdk/drag-drop): element not draggable when has initial transform … #22458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cdk/drag-drop): element not draggable when has initial transform … #22458
Conversation
@@ -347,6 +347,51 @@ describe('CdkDrag', () => { | |||
})); | |||
}); | |||
|
|||
describe('mouse dragging when initial transform is none', () => { | |||
it('should drag an element freely to a particular position', fakeAsync(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we only really need this test, the rest can be removed.
src/cdk/drag-drop/drag-ref.ts
Outdated
// 'none' is valid css transform value but none + translate3d(x, y, z) is invalid. | ||
// Note that we apply our own transform before the user's, because things like | ||
// rotation can affect which direction the element will be translated towards. | ||
this._rootElement.style.transform = this._initialTransform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than checking here, it might be easier to check inside _applyRootElementTransform
before saving the value to _initialTransform
. That way we don't have to account for it again if we add any new places that read from _initialTransform
.
</div> | ||
` | ||
}) | ||
class StandaloneDraggableWithInitialTransformNone { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than creating a new fixture, you should be able to reuse the StandaloneDraggable
and adjust the test. E.g. something like:
const fixture = createComponent(StandaloneDraggable);
fixture.detectChanges();
const dragElement = fixture.componentInstance.dragElement.nativeElement;
dragElement.style.transform = 'none';
dragElementViaMouse(fixture, dragElement, 50, 100);
expect(dragElement.style.transform).toBe('translate3d(50px, 100px, 0px)');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4eaab40
to
845154c
Compare
845154c
to
101e3ff
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
existing cdkDrag will concat current transform value with what's calculated by cdkDrag.
cdkDrag broken when initial transform value is none because
transform: none
is valid css buttransform: none translate3d(x, y, x)
is not.i've added test cases to test cdkDrag that has initial
transform: none
value