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: topItemCount for TableVirtuoso #1147

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Conversation

yuta4j1
Copy link
Contributor

@yuta4j1 yuta4j1 commented Oct 13, 2024

Resolves #1130 .
I wanted to separate topItems from items as in Virtuoso.tsx, but in the case of TableVirtsuoso.tsx, the Items component contains a TableBodyComponent, so I could not put a TableRowComponent outside of it, and So, this is how it is implemented.
If you have any ideas for a better implementation, I'd be happy to point them out.


if (statefulTotalCount === 0 && EmptyPlaceholder) {
return <EmptyPlaceholder {...contextPropIfNotDomElement(EmptyPlaceholder, context)} />
}

const paddingTop = listState.offsetTop + paddingTopAddition + deviation
const topItems = (showTopList ? listState.topItems : []).map((item) => {
Copy link
Owner

Choose a reason for hiding this comment

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

This is duplicating the const items block below. I would rather have this refactored into a common routine to reduce size and avoid potential bugs because things changed in one of the blocks but were forgotten into the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made topItems and items common. Does it match your image?
78bd0c6

const topItems = (showTopList ? listState.topItems : []).map((item) => {
const index = item.originalIndex!
const key = computeItemKey(index + firstItemIndex, item.data, context)
const offsetTop = listState.topItems.reduce((acc, item, itemIndex) => {
Copy link
Owner

Choose a reason for hiding this comment

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

This nested loop can theoretically cause performance problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@petyosi
Copy link
Owner

petyosi commented Oct 14, 2024

Looks good, I will test and merge if everything is ok.

@petyosi petyosi merged commit 3405b64 into petyosi:master Oct 15, 2024
@petyosi
Copy link
Owner

petyosi commented Oct 15, 2024

@yuta4j1 Thank you for your contribution :).

Copy link

🎉 This PR is included in version 4.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yuta4j1 yuta4j1 deleted the fix-1130 branch October 17, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TableVirtuoso does not render topItemCount items
2 participants