-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(cdk/drag-drop): allow using cdkDragRootElement w/ comment tag #23596
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
Conversation
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.
This also needs a unit test. I suspect that the regression was caused by #23293.
420c99b
to
35afdf4
Compare
src/cdk/drag-drop/directives/drag.ts
Outdated
const element = this.element.nativeElement; | ||
const element = this.element.nativeElement as HTMLElement; | ||
// Comment tag doesn't have closest method, so use parent's one. | ||
const closestFn = (element.closest || element.parentElement?.closest)?.bind(this); |
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.
Sorry for nitpicking, but I think that you'll have to push again anyway because the CI didn't run.
Using bind
here is a little wasteful since it creates a new function. It would be better to use apply
or call
.
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.
@crisbeto thanks! 🙂
35afdf4
to
f968ef6
Compare
This comment has been minimized.
This comment has been minimized.
Looks like the new test is failing. |
f968ef6
to
53cfe72
Compare
53cfe72
to
8a6cad8
Compare
I have no idea why, but I was passing |
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. Marking this as a P2, because it fixes a regression.
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. |
Makes possible to use the following syntax to make dialogs draggable:
Because of
ng-container
renders to comment and HTML comment doesn't have.closest()
method we can useelement.parentElement.closest
forrootElementSelector
searching.P.S.: provided HTML code was working till cdk v12.2.6 and stopped working on >= v13.0.0-next.2. Not sure what was changed.