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 province contacts page #134

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

suliskh
Copy link

@suliskh suliskh commented Jul 18, 2021

Closes #125

Description

Add virtualizations of the province contacts list page

Use react-virtual lib to provide virtualization. I chose react-virtual instead of react-window because it has a smaller bundle size and its headless mechanism that allowing us to have more control of the rendered markup.

How has this been tested?

  • Live test on a real mobile device (Android 11)

    20210720_142810.1.mp4
  • 6x CPU slowdown profiling using Chrome DevTools

    Profiling - Before Profiling - After
  • Overall performance testing using https://web.dev/measure

    Lighthouse - Before Lighthouse - After

Current Tasks

  • Use the virtualization lib
  • Profile render time before and after this PR

Caveat and Discussion

Both react-window and react-virtual rely on a fixed height of the container to make the virtualization possible. In this PR, I set the list container height to be 100vh. As you can see from the above video demo, those result in the page having a double vertical scrollbar and unexpected scrolling experience which unfortunately I can't fix. Despite resulting in a better perf, IMO it doesn't worth the UX tradeoff.

@netlify
Copy link

netlify bot commented Jul 18, 2021

❌ Deploy Preview for wargabantuwarga failed.

🔨 Explore the source changes: d1e5a9e

🔍 Inspect the deploy log: https://app.netlify.com/sites/wargabantuwarga/deploys/610f9d971c94f60007828f9a

@suliskh suliskh force-pushed the fix/provinces-virtualization branch from 57339d1 to 482696e Compare July 20, 2021 06:38
@suliskh suliskh changed the title Add react-virtualized-auto-sizer and react-window as depedencies Add virtualization in province contacts page Jul 20, 2021
@andriawan
Copy link
Collaborator

andriawan commented Jul 20, 2021

could it be possible to implement totalSize as in this sample https://github.com/tannerlinsley/react-virtual#sample ?
any suggestion mas @zainfathoni?

position: "absolute",
top: 0,
left: 0,
width: "100%",
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
width: "100%",
height: `${rowVirtualizer.totalSize}px`,
width: "100%",

As @andriawan mentioned in his comment, have you tried doing this before?

Copy link
Author

@suliskh suliskh Jul 21, 2021

Choose a reason for hiding this comment

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

Yes, I've tried that, Mas, but unfortunately, it does not solve the main problem. Instead, I use totalSize to create an inner container of the list.

My actual concern is that we ended up having two vertical scrolls which I think is a bad scrolling experience, particularly on a mobile viewport. Are you okay with that behaviour, Mas? Would you mind confirming that scrolling experience yourself via the deploy preview, Mas @zainfathoni? :sungkem:

Double.Scroll.mp4
Double.Scroll.Mobile.mp4

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I am aware of it. In my opinion, before we need to merge this, we need to simplify the Search and Filter UI, because it takes too much space.

I think we can use something like this to squeeze the filtering & sorting UI into a smaller space, what do you think, @resir014?

Upload.from.GitHub.for.iOS.MOV

If we can squeeze the filtering & sorting UI into a smaller space, we can make the height of the page absolute, so no more scrolling on the page itself.

Copy link
Member

@resir014 resir014 Jul 21, 2021

Choose a reason for hiding this comment

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

Yes, agree @zainfathoni.

I'm not sure about the double scroll though. It feels a little too janky. Unless we can simplify the filter to make the virtualised list fit the whole screen we should hold off on merging this.

Copy link
Member

Choose a reason for hiding this comment

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

@zainfathoni Let's create a separate issue for the simplified filter. I can work on this later tonight.

package.json Outdated Show resolved Hide resolved
suliskh and others added 3 commits July 20, 2021 19:11
Co-authored-by: Zain Fathoni <zain.fathoni@gmail.com>
…gabantuwarga.com into fix/provinces-virtualization
@resir014 resir014 mentioned this pull request Jul 21, 2021
2 tasks
@resir014 resir014 added the blocked Blocked by something else label Jul 21, 2021
@resir014
Copy link
Member

Added the blocked tag here b/c we need to wait on merging until #244 is finished.

@zainfathoni
Copy link
Member

#244 is done, so you can continue working on it, @suliskh. Thanks!

@zainfathoni zainfathoni added enhancement New feature or request ux User Experience and removed blocked Blocked by something else labels Jul 25, 2021
@zainfathoni
Copy link
Member

@resir014 what if we implement the virtualisation like how Netlify provides the double scroll experience?

Upload.from.GitHub.for.iOS.MOV

@codecov
Copy link

codecov bot commented Aug 8, 2021

Codecov Report

Merging #134 (d1e5a9e) into main (20ea213) will increase coverage by 2.53%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #134      +/-   ##
==========================================
+ Coverage   76.28%   78.81%   +2.53%     
==========================================
  Files         110      110              
  Lines        1265     1270       +5     
  Branches      416      416              
==========================================
+ Hits          965     1001      +36     
+ Misses        294      263      -31     
  Partials        6        6              
Impacted Files Coverage Δ
components/contact-list-item.tsx 57.14% <57.14%> (+4.51%) ⬆️
components/contact-list.tsx 100.00% <100.00%> (ø)
components/ui/scroll-arrow.tsx 72.22% <0.00%> (+72.22%) ⬆️
pages/_app.tsx 89.47% <0.00%> (+89.47%) ⬆️
components/layout/layout-root.tsx 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20ea213...d1e5a9e. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ux User Experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement virtualization for list views
4 participants