-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGridPro] Fix missing border in right-pinned columns #4197
Merged
cherniavskii
merged 29 commits into
mui:next
from
cherniavskii:showCellRightBorder-right-pinned-columns
Dec 13, 2022
Merged
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
efd8aed
fix showCellRightBorder with columns pinned to the right
cherniavskii adae7ba
extract getBorderColor to styleUtils
cherniavskii 7d9b595
add global theme control to storybook
cherniavskii 5829054
add story
cherniavskii b9322f9
add unit test
cherniavskii 744ffe3
empty commit to trigger codesandbox ci
cherniavskii 73c8eaa
Merge branch 'master' into showCellRightBorder-right-pinned-columns
cherniavskii c5ba561
Merge branch 'master' into showCellRightBorder-right-pinned-columns
cherniavskii f0c1a47
Merge branch 'master' into showCellRightBorder-right-pinned-columns
cherniavskii e8d4e08
make `withBorder` only set border color
cherniavskii 4a80b54
update api docs
cherniavskii ef756e4
Merge branch 'master' into showCellRightBorder-right-pinned-columns
cherniavskii 2794e4f
Merge branch 'master' into showCellRightBorder-right-pinned-columns
cherniavskii c4aebba
split withRightBorder class into 2 separate classes
cherniavskii bed8f3b
build api docs
cherniavskii e3a1f3d
Merge branch 'master' into showCellRightBorder-right-pinned-columns
cherniavskii 65a56cb
Merge branch 'next' into showCellRightBorder-right-pinned-columns
cherniavskii 9677dab
eslint
cherniavskii ccf5cdb
add border to the right-pinned columns when showCellRightBorder=true
cherniavskii 96a23a7
apply border color using `withBorderColor` class
cherniavskii 2545feb
remove unused ownerState
cherniavskii 9b287b9
rename `showCellRightBorder` prop
cherniavskii 9f0a370
Merge branch 'next' into showCellRightBorder-right-pinned-columns
cherniavskii d9537fb
rename `showColumnRightBorder` prop
cherniavskii 709a2e9
document renamed CSS class
cherniavskii 8b5131e
remove 'withBorder' class usages
cherniavskii 4f14f00
avoid using borderColor
cherniavskii 938da8e
Merge branch 'next' into showCellRightBorder-right-pinned-columns
cherniavskii 09856d8
fix visual regressions
cherniavskii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { darken, lighten, alpha, Theme } from '@mui/material/styles'; | ||
|
||
export function getBorderColor(theme: Theme) { | ||
return theme.palette.mode === 'light' | ||
? lighten(alpha(theme.palette.divider, 1), 0.88) | ||
: darken(alpha(theme.palette.divider, 1), 0.68); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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'm not sure if this is the right approach. Currently, if
showCellRightBorder
is on the cells receive the.MuiDataGrid-withBorder
class. This class is specifically to change the border of the cells. Here we're changing the meaning ofshowCellRightBorder
by applying a border not to the pinned cells but to their container. If the user wants to change the color of the cell border he will have to change in two places: here and in.MuiDataGrid-withBorder
.My proposal is to change
.MuiDataGrid-withBorder
to only set the border color, then the cells will set the border width/style on the appropriate side.For v6 I agree to rename this prop to
showCellVerticalBorder
or other name.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.
Good point!
But there's more places with border color anyway:
mui-x/packages/grid/x-data-grid/src/components/containers/GridRootStyles.ts
Line 66 in 140f394
mui-x/packages/grid/x-data-grid/src/components/containers/GridRootStyles.ts
Line 169 in 140f394
mui-x/packages/grid/x-data-grid/src/components/containers/GridRootStyles.ts
Line 249 in 140f394
Maybe we should add separate
borderColor
class and apply it everywhere border is used?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.
Yeah but these other borders affect other parts, not the cells. Currently,
.MuiDataGrid-withBorder
only impacts the cell border.We'll have two classes for borders. In v6 I think we can unify this behavior and apply
MuiDataGrid-withBorder
to the grid instead, not the cells. Then, we can have a single border color. It could also be a CSS variable, to be used incolor
.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.
Ok, I've split
withBorder
styles into two classes:withBorder
that appliesborder-color
onlywithRightBorder
that appliesborder-right-width
andborder-right-style
onlyI've also used
withBorder
to apply border color to right-pinned container.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.
We miss a
withLeftBorder
applyingborder-left-width
andborder-right-style
to the cell, not to the right pinned columns container.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.
There are 2 problems with that:
I don't see a way to set
showLeftBorder={true}
only for first cells in the right-pinned section.Applying left border to cell instead of right pinned columns container results in double border:
borderLeft on right-pinned columns container
borderLeft on cell
I didn't find a way to avoid this double border.
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've renamed
showCellRightBorder
toshowCellVerticalBorder
,showColumnRightBorder
toshowColumnVerticalBorder
and addedwithBorderColor
CSS class that sets the border color for both cells and column headers