Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[DataGrid] Fix scroll to cell logic for keyboard navigating cells and drag selection with pinned columns #14550
[DataGrid] Fix scroll to cell logic for keyboard navigating cells and drag selection with pinned columns #14550
Changes from 8 commits
34fe7fc
9b3a340
dd2fec7
4abd708
42ad3d7
60a6fbc
cb6491f
963da1a
b7e32f6
d1f2dc2
201adf5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
pinnedSelectedBackgroundColor
here can be either a CSS color value or a CSS variable.getPinnedBackgroundStyles
assumes it's a CSS color value and uses theblend
function, which won't work with CSS variables.This made me realize that we missed a test for the DataGrid rendered inside of the
CssVarsProvider
, so I opened #14662 to add one.We have to make sure we don't try to
blend
CSS variables.This also reminds me about this PR: #12901.
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.
@cherniavskii I am not sure of the best way to handle this.
color-mix
would work well besides the versions of Safari that do not support it. It doesn't look like there is another way to blend colors with CSS variables otherwise.I don't know if we can add an exception to our browser support specifically for cases where
CssVarsProvider
is used? 😅The only other way I can think to achieve this effect with CSS variables is by having an inner element in pinned cells to apply the transparent hover/selected background-color to. Not sure this is viable though, considering the performance implications of having an extra element for every pinned cell. https://codepen.io/KenanYusuf/pen/WNqVXqM
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.
@KenanYusuf, not sure it helps, but we ran into similar problems when migrating to DataGrid v7 due to our custom styles. Some of our pinned cells had backgrounds with alpha values. Therefore, the non-pinned cells were visible behind them.
We attempted to solve this using
color-mix
. The result worked but was very hard to read and extend in our case.We opted for the two-element approach you described, but instead of adding one additional element per cell, we added one sticky background element with the width of the pinned cells.
Details
We added the sticky background to the row using DataGrid
slots
. We had to place it between row and pinned cells usingz-index
, but you could probably just make it a container element of the pinned cells.The additional sticky background always has the same background color as the row. If the row is selected using row selection, the color of the additional sticky background changes too. If only a pinned cell is selected using cell selection, only the background color of the pinned cell changes.
We didn't run into noticeable performance problems. If you consider pinned left and pinned right, it's only two more divs in each row.
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.
Changed the param names to be direction agnostic, since this is used for horizontal and vertical scrolling