-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[DataGrid] Add scroll shadows and fix scrollbar overlap #16476
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
Merged
cherniavskii
merged 63 commits into
mui:master
from
KenanYusuf:vertical-scrollbar-include-pinned-rows
Sep 29, 2025
Merged
Changes from 7 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
7816345
[data grid] Update vertical position to cover pinned rows
KenanYusuf 0737cae
fix build
KenanYusuf 80ae0f9
fix
KenanYusuf 673393e
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 672d1f9
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 5a87515
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 432e5c8
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf b610de5
fix vertical scrollbar
KenanYusuf 82ae8d6
add aria-hidden to presentational scrollbar
KenanYusuf 57a2d0b
fix scrollbar filler for pinned right columns
KenanYusuf 9707912
fix skeleton loader styles
KenanYusuf 4eec5f3
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 4b6fda9
revert changes
KenanYusuf de7bfb5
fix scrollbarInnerHeight
KenanYusuf e89a6a9
fix scrolling vertically when there is horizontal scroll
KenanYusuf 888f749
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 5d87e4a
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 04b6311
add scroll shadows
KenanYusuf d1dba84
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 83f916c
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 62603e3
remove border from filler cells
KenanYusuf 8a42578
round scroll values
KenanYusuf 2b7881e
improve shadow styles
KenanYusuf 35fafe2
improve var naming
KenanYusuf a9a2668
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf beeb89b
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 1642174
add null check
KenanYusuf bf0fc47
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf f44d1b3
fix vertical scrollbar size and position
KenanYusuf 0ec921a
alternate approach to hiding vertical scrollbar on overlays
KenanYusuf 6dd3eed
export type
KenanYusuf fbc9c83
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf aeb9ff4
adjust shadow
KenanYusuf 872530a
fix space for horizontal scrollbar in list view
KenanYusuf fe55f40
add missing dependency
KenanYusuf 2386c9c
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 67c3a42
update background color in dark mode
KenanYusuf 825be6d
update light mode background color
KenanYusuf bedd100
refine shadows
KenanYusuf 24ea113
add border to scrollbar filler on header filter rows
KenanYusuf 684f386
adjust shadows _again_
KenanYusuf 81b3a90
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 392d9a0
fix scroll shadows in RTL
KenanYusuf 7d5734e
lint
KenanYusuf 4d40332
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
KenanYusuf 3c42491
remove styles
KenanYusuf f6a0ce3
memoize style
KenanYusuf 526072a
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
cherniavskii 6648147
apply dimension changes to the virtualizer
cherniavskii 144a32e
fix ts error
cherniavskii e906325
add pinnedColumnsSectionSeparator prop
cherniavskii eecf0e5
do not hide horizontal scroll for loading overlay
cherniavskii 0e0a327
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
cherniavskii 1047df5
evaluate scroll shadow visibility in effect
cherniavskii c4d411a
fix error where horizontal scroll was disable instead of vertical one
cherniavskii 17b57f1
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
cherniavskii 747f6c5
lint: extract type
cherniavskii 26d7561
add pinnedRowsSectionSeparator prop
cherniavskii afd3eff
update demo
cherniavskii 092ad68
reduce the diff
cherniavskii 367db03
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
cherniavskii 7cb61c9
Merge branch 'master' into vertical-scrollbar-include-pinned-rows
cherniavskii 612f420
border+shadow => border-and-shadow
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -49,20 +49,21 @@ const Scrollbar = styled('div')({ | |
const ScrollbarVertical = styled(Scrollbar)({ | ||
width: 'var(--size)', | ||
height: | ||
'calc(var(--DataGrid-hasScrollY) * (100% - var(--DataGrid-topContainerHeight) - var(--DataGrid-bottomContainerHeight) - var(--DataGrid-hasScrollX) * var(--DataGrid-scrollbarSize)))', | ||
'calc(var(--DataGrid-hasScrollY) * (100% - var(--DataGrid-headerHeight) - var(--DataGrid-hasScrollX) * var(--DataGrid-scrollbarSize)))', | ||
overflowY: 'auto', | ||
overflowX: 'hidden', | ||
// Disable focus-visible style, it's a scrollbar. | ||
outline: 0, | ||
'& > div': { | ||
width: 'var(--size)', | ||
}, | ||
top: 'var(--DataGrid-topContainerHeight)', | ||
right: '0px', | ||
top: 'var(--DataGrid-headerHeight)', | ||
right: 0, | ||
}); | ||
|
||
const ScrollbarHorizontal = styled(Scrollbar)({ | ||
width: '100%', | ||
width: | ||
'calc(var(--DataGrid-hasScrollX) * (100% - var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize)))', | ||
height: 'var(--size)', | ||
overflowY: 'hidden', | ||
overflowX: 'auto', | ||
|
@@ -71,7 +72,15 @@ const ScrollbarHorizontal = styled(Scrollbar)({ | |
'& > div': { | ||
height: 'var(--size)', | ||
}, | ||
bottom: '0px', | ||
bottom: 0, | ||
}); | ||
|
||
export const ScrollbarCorner = styled(Scrollbar)({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
width: 'var(--size)', | ||
height: 'var(--size)', | ||
right: 0, | ||
bottom: 0, | ||
overflow: 'scroll', | ||
}); | ||
|
||
const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProps>( | ||
|
@@ -81,25 +90,19 @@ const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProp | |
const isLocked = React.useRef(false); | ||
const lastPosition = React.useRef(0); | ||
const scrollbarRef = React.useRef<HTMLDivElement>(null); | ||
const contentRef = React.useRef<HTMLDivElement>(null); | ||
const classes = useUtilityClasses(rootProps, props.position); | ||
const dimensions = useGridSelector(apiRef, gridDimensionsSelector); | ||
|
||
const propertyDimension = props.position === 'vertical' ? 'height' : 'width'; | ||
const propertyScroll = props.position === 'vertical' ? 'scrollTop' : 'scrollLeft'; | ||
const propertyScrollPosition = props.position === 'vertical' ? 'top' : 'left'; | ||
const hasScroll = props.position === 'vertical' ? dimensions.hasScrollX : dimensions.hasScrollY; | ||
|
||
const contentSize = | ||
dimensions.minimumSize[propertyDimension] + (hasScroll ? dimensions.scrollbarSize : 0); | ||
|
||
const scrollbarSize = | ||
props.position === 'vertical' | ||
? dimensions.viewportInnerSize.height | ||
: dimensions.viewportOuterSize.width; | ||
|
||
const scrollbarInnerSize = | ||
scrollbarSize * (contentSize / dimensions.viewportOuterSize[propertyDimension]); | ||
props.position === 'horizontal' | ||
? dimensions.minimumSize[propertyDimension] | ||
: dimensions.minimumSize[propertyDimension] - | ||
dimensions.headersTotalHeight - | ||
(dimensions.hasScrollX ? dimensions.scrollbarSize : 0); | ||
|
||
const onScrollerScroll = useEventCallback(() => { | ||
const scrollbar = scrollbarRef.current; | ||
|
@@ -121,8 +124,7 @@ const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProp | |
} | ||
isLocked.current = true; | ||
|
||
const value = scrollPosition[propertyScrollPosition] / contentSize; | ||
scrollbar[propertyScroll] = value * scrollbarInnerSize; | ||
scrollbar[propertyScroll] = scrollPosition[propertyScrollPosition]; | ||
}); | ||
|
||
const onScrollbarScroll = useEventCallback(() => { | ||
|
@@ -139,8 +141,7 @@ const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProp | |
} | ||
isLocked.current = true; | ||
|
||
const value = scrollbar[propertyScroll] / scrollbarInnerSize; | ||
scroller[propertyScroll] = value * contentSize; | ||
scroller[propertyScroll] = scrollbar[propertyScroll]; | ||
}); | ||
|
||
useOnMount(() => { | ||
|
@@ -155,11 +156,6 @@ const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProp | |
}; | ||
}); | ||
|
||
React.useEffect(() => { | ||
const content = contentRef.current!; | ||
content.style.setProperty(propertyDimension, `${scrollbarInnerSize}px`); | ||
}, [scrollbarInnerSize, propertyDimension]); | ||
|
||
const Container = props.position === 'vertical' ? ScrollbarVertical : ScrollbarHorizontal; | ||
|
||
return ( | ||
|
@@ -179,7 +175,10 @@ const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProp | |
event.target.blur(); | ||
}} | ||
> | ||
<div ref={contentRef} className={classes.content} /> | ||
<div | ||
className={classes.content} | ||
style={{ [propertyDimension]: `${scrollbarInnerSize}px` }} | ||
KenanYusuf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
/> | ||
</Container> | ||
); | ||
}, | ||
|
cherniavskii marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.