Skip to content
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

feat(Table): add virtualization #2489

Open
wants to merge 97 commits into
base: master
Choose a base branch
from
Open

Conversation

tewarig
Copy link
Contributor

@tewarig tewarig commented Jan 22, 2025

Description

Changes

Additional Information

dev checklist -
[ x ] vtable height be changed
[ x ] check why check box look weird ?
[ x ] need to make row similar to normal table
[ x ] should check the space of table.
[ x ] vtable should be aligned as normal table.
[ x ] hover actions
[ x ] sticky column
[ x ] table header
[ x ] fix ts error
[ x ] unified styles for virtualized table
[ x ] add tests

Component Checklist

  • Update Component Status Page
  • Perform Manual Testing in Other Browsers
  • Add KitchenSink Story
  • Add Interaction Tests (if applicable)
  • Add changeset

Comment on lines 203 to 210
const isVirtualized = (React.isValidElement<{
header?: () => React.ReactElement;
children?: React.ReactNode;
}>(tableRootComponent) &&
Array.isArray(tableRootComponent.props?.children) &&
tableRootComponent.props.children?.length &&
React.isValidElement<{ children?: React.ReactNode }>(tableRootComponent.props?.children[1]) &&
typeof tableRootComponent.props?.children[1]?.props.children === 'function') as boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a little complex 🙈 Can you add comment on how this checks if table is virualized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored this. no jsx walking

Comment on lines 79 to 80
paddingX="0"
paddingY="0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is allowed in TS 🙈 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these different story files? we can have one TableVirtualized.stories.tsx and add virtualized tables there right?

Comment on lines 65 to 82
if (isVirtualized) {
if (
React.isValidElement<{ header?: () => React.ReactElement }>(tableRootComponent) &&
tableRootComponent?.props.header
) {
if (React.isValidElement(tableRootComponent?.props.header())) {
const tableHeaderRow = tableRootComponent.props.header().props.children;
if (
React.isValidElement<{ children?: React.ReactNode }>(tableHeaderRow) &&
tableHeaderRow.props.children
) {
const tableHeaderCells = React.Children.toArray(tableHeaderRow.props.children);
return tableHeaderCells.length;
}
}
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be needed as we discussed

@@ -156,8 +199,17 @@ const _Table = <Item,>({
undefined,
);
const [hasHoverActions, setHasHoverActions] = React.useState(false);
const tableRootComponent = children([]);
const isVirtualized = (React.isValidElement<{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -12,6 +12,7 @@ const ComponentIds = {
TableFooter: 'TableFooter',
TableFooterRow: 'TableFooterRow',
TableFooterCell: 'TableFooterCell',
VirtualizedTable: 'VirtualizedTable',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't exist right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is being used in TableVirtualizedWrapper

Comment on lines 110 to 111
<TableBody<Item>>
{(tableItem, index) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<TableBody<Item>>
{(tableItem, index) => (
<TableBody>
{(tableItem: Item, index) => (

{(tableData) => (
<>
{() => (
<TableVirtualizedWrapper rowHeight={() => 57}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove virtualization from Basic story I guess

tableRootComponent.props.children?.length &&
React.isValidElement<{ children?: React.ReactNode }>(tableRootComponent.props?.children[1]) &&
typeof tableRootComponent.props?.children[1]?.props.children === 'function') as boolean;
const isVirtualized = getComponentId(tableRootComponent) === ComponentIds.VirtualizedTable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👯

Copy link
Member

@saurabhdaware saurabhdaware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@saurabhdaware saurabhdaware changed the title feat: table virtualization feat(Table): add virtualization Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants