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

Add virtualization in sites table #1054

Closed
wants to merge 5 commits into from

Conversation

K-Markopoulos
Copy link
Collaborator

The goal is to improve the performance of the sites table in /map route, by adding virtualization. Currently we do not paginate the sites and when we fetch a few thousands sites, the UI is slow and may freeze.

  • Add react-window package which handles virtualization.
  • Add VirtualTable component "forked" from this sandbox, as react-window only works for lists and we need to make it work with tables.
  • Rename SiteTableBody -> SiteTable, it now renders both header (received from props) and body.
  • Rename SiteTable -> SiteTableContainer

@K-Markopoulos K-Markopoulos self-assigned this Nov 18, 2024
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@K-Markopoulos you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 463
- 322

55% TSX
44% Jest Snapshot (tests)
1% TSX (tests)
<1% JSON
<1% TypeScript

Generated lines of change

+ 27
- 0

Type of change

Feature - These changes are adding a new feature or improvement to existing code.

Copy link

github-actions bot commented Nov 18, 2024

Build succeeded and deployed at https://aqualink-app-1054.surge.sh
(hash 48b3707 deployed at 2024-11-19T16:19:56)

@ericboucher
Copy link
Member

Nice work!

  • I noticed a small visual glitch when scrolling down, the header moves slightly creating a visual glitch
  • clicking on a reef in the table is super slow on the staging env, but this might be due to the high number of points on the map and not the table? If it's the table then we should investigate.
  • Sorry I didn't think of that earlier but another option would be to use pagination instead. Do you have any thoughts on pagination vs virtualization in this case? Noting that a short-term goal is to put filters more at the center of the usage of the map "à la" Airbnb.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Nice work, no merge blocking issues found. Well commented code. Added a couple comments about possible (minor) issues.

Image of Frank T Frank T


Reviewed with ❤️ by PullRequest


/**
* Displays a virtualized list as table with optional header and footer.
* It basically accepts all of the same params as the original FixedSizeList.
Copy link

Choose a reason for hiding this comment

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

Nice comment here with reference link

◽ Compliment

Image of Frank T Frank T

const handleClick = (event: unknown, site: Row) => {
setSelectedRow(site.tableData.id);
const mapElement = document.getElementById('sites-map');
Copy link

Choose a reason for hiding this comment

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

nit - It is fine as is, but we could grab the mapElement after the dispatch calls.

🔹 Best Practices (Nice to have)

Image of Frank T Frank T

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, I'm making the change.

@@ -288,28 +336,30 @@
},
},
tableRow: {
position: 'static !important' as 'static',
cursor: 'pointer',
borderTop: `1px solid ${theme.palette.grey['300']}`,
},
});

type SiteTableBodyIncomingProps = {
Copy link

Choose a reason for hiding this comment

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

Should this be renamed from SiteTableBodyIncomingProps to SiteTableIncomingProps?

🔹 Naming (Nice to have)

Image of Frank T Frank T

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, nice catch 🎣 !

@K-Markopoulos
Copy link
Collaborator Author

K-Markopoulos commented Nov 19, 2024

@ericboucher

  • The visual glitch is unfortunately present because the items are absolute positioned on scroll. At first look I had not luck mitigating this issue, we will need to investigate it further.
  • The slowness is most likely because of the map, if there is no interaction with the map the page and the table is very fast. I tried to remove the map and the item clicking does cause any issue.
  • Pagination (server side) seems like a better solution to avoid fetching thousands of items. Virtualization is a quicker solution to avoid rendering all of them, if we are fetching thousands, let's not render them all at once. But adding pagination here might be tricky because the paginated items have to be in sync with the visible items in the map. There are some edge cases we need to figure out like, what happens when the map is completely zoomed out, if the map is fetching all items to display them then they are not paginated and we don't have a specific page to show. It can be achieved but it needs more thought.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest reviewed the updates made to #1054 up until the latest commit (48b3707). No further issues were found.

Reviewed by:

Image of Frank T Frank T

@ericboucher ericboucher reopened this Nov 19, 2024
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@K-Markopoulos you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✖️ This code review was cancelled. See Details

@ericboucher
Copy link
Member

Closing for now in favor of pagination but let's keep this in mind !

@ericboucher ericboucher closed this Dec 4, 2024
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.

2 participants