-
-
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
[XGrid] Make Infinite loading support rowCount
#1715
Closed
DanailH
wants to merge
32
commits into
mui:master
from
DanailH:feature/DataGrid-1247-rowCount-infite-loader
Closed
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
ada4c4d
Add support for detecting when virtual page changes
DanailH 21196bd
Initial version
DanailH ddc90de
Remove commented out code
DanailH 4c0a5b1
Add base skeleton row logic and styles
DanailH 1f94832
Make new skeleton components public
DanailH e520dbc
Sort out loading on scroll and sorting
DanailH dd7af2c
Fix filter functionality
DanailH b841f96
rename loadRows option to getRows
DanailH 4ab7cd0
resolve conflicts
DanailH 97c86a8
Remove dead code and fix tests
DanailH 802ff36
Fix styles
DanailH 9dd3579
Fix server pagination
DanailH 8bbbe71
Rename methods and decouple api method from grid option
DanailH 6222f1e
PR comments
DanailH 8fc923e
Fix trailing rows issue
DanailH 369cb68
Add tests
DanailH 60a7adc
Remove code
DanailH 11d936a
Finished tests
DanailH f9f2ab1
Add docs
DanailH 59aa187
Load one page more
DanailH 658879f
add story
DanailH f81a1cf
Update docs/src/pages/components/data-grid/rows/rows.md
DanailH 4290995
PR comments
DanailH 323f10a
Merge branch 'feature/DataGrid-1247-rowCount-infite-loader' of github…
DanailH 02b02de
resolve conflict
DanailH b481127
run prettier
DanailH 42f0830
format docs api
DanailH c08eb4b
Fix docs
DanailH 2007edd
Fix conflicts
DanailH cdcdfee
Resolve conflicts
DanailH f96f635
Add infniteLoaderMode option
DanailH 828a186
Fix tests
DanailH 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
42 changes: 42 additions & 0 deletions
42
packages/grid/_modules_/grid/components/cell/GridSkeletonCell.tsx
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,42 @@ | ||
import * as React from 'react'; | ||
import clsx from 'clsx'; | ||
import { GRID_SKELETON_CELL_CSS_CLASS } from '../../constants/cssClassesConstants'; | ||
|
||
export interface GridSkeletonCellProps { | ||
colIndex: number; | ||
height: number; | ||
rowIndex: number; | ||
showRightBorder?: boolean; | ||
width: number; | ||
} | ||
|
||
export const GridSkeletonCell = React.memo((props: GridSkeletonCellProps) => { | ||
DanailH marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { colIndex, height, rowIndex, showRightBorder, width } = props; | ||
|
||
const cellRef = React.useRef<HTMLDivElement>(null); | ||
const cssClasses = clsx(GRID_SKELETON_CELL_CSS_CLASS, { | ||
'MuiDataGrid-withBorder': showRightBorder, | ||
}); | ||
|
||
const style = { | ||
minWidth: width, | ||
maxWidth: width, | ||
lineHeight: `${height - 1}px`, | ||
minHeight: height, | ||
maxHeight: height, | ||
}; | ||
|
||
return ( | ||
<div | ||
ref={cellRef} | ||
className={cssClasses} | ||
role="cell" | ||
data-rowindex={rowIndex} | ||
aria-colindex={colIndex} | ||
style={style} | ||
tabIndex={-1} | ||
/> | ||
); | ||
}); | ||
|
||
GridSkeletonCell.displayName = 'GridSkeletonCell'; | ||
DanailH marked this conversation as resolved.
Show resolved
Hide resolved
|
60 changes: 60 additions & 0 deletions
60
packages/grid/_modules_/grid/components/cell/GridSkeletonRowCells.tsx
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,60 @@ | ||
import * as React from 'react'; | ||
import { GridColumns } from '../../models/index'; | ||
import { GridApiContext } from '../GridApiContext'; | ||
import { gridDensityRowHeightSelector } from '../../hooks/features/density/densitySelector'; | ||
import { useGridSelector } from '../../hooks/features/core/useGridSelector'; | ||
import { GridSkeletonCell } from './GridSkeletonCell'; | ||
|
||
interface SkeletonRowCellsProps { | ||
columns: GridColumns; | ||
extendRowFullWidth: boolean; | ||
firstColIdx: number; | ||
hasScrollX: boolean; | ||
hasScrollY: boolean; | ||
lastColIdx: number; | ||
rowIndex: number; | ||
showCellRightBorder: boolean; | ||
} | ||
|
||
export const GridSkeletonRowCells = React.memo((props: SkeletonRowCellsProps) => { | ||
const { | ||
columns, | ||
firstColIdx, | ||
hasScrollX, | ||
hasScrollY, | ||
lastColIdx, | ||
rowIndex, | ||
showCellRightBorder, | ||
} = props; | ||
const apiRef = React.useContext(GridApiContext); | ||
const rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector); | ||
|
||
const skeletonCellsProps = columns.slice(firstColIdx, lastColIdx + 1).map((column, colIdx) => { | ||
const colIndex = firstColIdx + colIdx; | ||
const isLastColumn = colIndex === columns.length - 1; | ||
const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY; | ||
const showRightBorder = !isLastColumn | ||
? showCellRightBorder | ||
: !removeLastBorderRight && !props.extendRowFullWidth; | ||
|
||
const skeletonCellProps = { | ||
field: column.field, | ||
width: column.width!, | ||
height: rowHeight, | ||
showRightBorder, | ||
rowIndex, | ||
colIndex, | ||
}; | ||
|
||
return skeletonCellProps; | ||
}); | ||
|
||
return ( | ||
<React.Fragment> | ||
{skeletonCellsProps.map((skeletonCellProps) => ( | ||
<GridSkeletonCell key={skeletonCellProps.field} {...skeletonCellProps} /> | ||
))} | ||
</React.Fragment> | ||
); | ||
}); | ||
GridSkeletonRowCells.displayName = 'GridSkeletonRowCells'; |
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
Oops, something went wrong.
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.
Instead of hardcoding different types of rows. How about we add an API to turn the loading state programmatically on some cells?
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 would even argue that we could breakdown this effort once we get a good enough POC of the integration to have the skeleton standalone, and maybe use it for the infinite loading use case.
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 agree that that is not the best solution but there is already a ticket for changing the loading visuals once this initial version is merged #1685
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 had forgotten about #1685. In this case, I propose we do #1685 first or we start here without any skeleton, no preferences. But whatever is necessary to focus on one problem at the time.
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 is that without skeleton rows this feature doesn't work at all because it will just display empty rows. The UX wouldn't be great.