-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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): avoid conflicts with sticky table headers #22864
fix(cdk/drag-drop): avoid conflicts with sticky table headers #22864
Conversation
The Material table with sticky headers sets its `position` as `!important` which ends up overriding the dragging styles. These changes rework the internals to use `setProperty` instead of `element.style.position` which allows us to set the `position` as `!important` as well. It also has the advantage that we can write the properties as dash case, instead of having to guess whether the vendor-prefixed properties are camel case or pascal case. Fixes angular#22781.
Thank you for the quick fix on this @crisbeto! |
/** Inline styles to be set as `!important` while dragging. */ | ||
const dragImportantProperties = new Set([ | ||
// Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781. | ||
'position' | ||
]); | ||
|
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.
How problematic would it be to alternatively remove the !important
from mat-table
? My inclination would be to avoid an !important
arms race by avoiding it completely.
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.
The problem with removing the !important
is that our sticky header selector currently has really low specificity and can be overwritten by styles that have been encapsulated by Angular. See #20558.
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
The Material table with sticky headers sets its `position` as `!important` which ends up overriding the dragging styles. These changes rework the internals to use `setProperty` instead of `element.style.position` which allows us to set the `position` as `!important` as well. It also has the advantage that we can write the properties as dash case, instead of having to guess whether the vendor-prefixed properties are camel case or pascal case. Fixes #22781. (cherry picked from commit 6cfb549)
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. |
The Material table with sticky headers sets its
position
as!important
which ends up overriding the dragging styles. These changes rework the internals to usesetProperty
instead ofelement.style.position
which allows us to set theposition
as!important
as well. It also has the advantage that we can write the properties as dash case, instead of having to guess whether the vendor-prefixed properties are camel case or pascal case.Fixes #22781.