-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[DataGrid] Update vertical scrollbar position to cover pinned rows #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
Open
KenanYusuf
wants to merge
14
commits into
mui:master
Choose a base branch
from
KenanYusuf:vertical-scrollbar-include-pinned-rows
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 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 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,17 @@ 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.width | ||
: dimensions.minimumSize.height - dimensions.headersTotalHeight; | ||
|
||
const onScrollerScroll = useEventCallback(() => { | ||
const scrollbar = scrollbarRef.current; | ||
|
@@ -121,8 +122,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 +139,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 +154,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 +173,10 @@ const GridVirtualScrollbar = forwardRef<HTMLDivElement, GridVirtualScrollbarProp | |
event.target.blur(); | ||
}} | ||
> | ||
<div ref={contentRef} className={classes.content} /> | ||
<div | ||
className={classes.content} | ||
style={{ [propertyDimension]: `${scrollbarInnerSize}px` }} | ||
/> | ||
</Container> | ||
); | ||
}, | ||
|
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.
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 is the easiest way to ensure the horizontal scrollbar is the correct width and the vertical and corner scrollbar are hidden. Also removes the need for fillers in the skeleton loader rows.