-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[IndexTable] Fix UX / jank when resizing #4033
[IndexTable] Fix UX / jank when resizing #4033
Conversation
NOTE that I didn't add any test cases for this--this behavior hinges on being able to grab dimensions from the dom, which isn't possible with our test setup (afaik). |
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.
Love how smooth this is looking 😍
Co-authored-by: Andrew Musgrave <[email protected]>
…ps://github.com/Shopify/polaris-react into lh/index-table-sticky-header-alignment-and-jank
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.
LGTM! ✅
@@ -16,6 +18,11 @@ import {ScrollContainer} from '../components'; | |||
import {SelectionType} from '../../../utilities/index-provider'; | |||
import {AfterInitialMount} from '../../AfterInitialMount'; | |||
|
|||
jest.mock('../utilities', () => ({ | |||
...(jest.requireActual('../utilities') as any), |
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.
Why was casting needed here?
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.
bad copy paste 🙈
WHY are these changes introduced?
Resolves #3991.
The IndexTable currently has some UX, jank, and performance issues when resizing. This PR aims to address a lot of these by making UX and performance fixes to make this resize buttery-smooth.
WHAT is this pull request doing?
1) Fixed sticky header alignment issues
All the sticky headers are sized on load and not resized when the window width changes.
👀 before (watch the Location column) 👀
2.mp4
👀 after (watch the Location column) 👀
6.mp4
2) Fixed first (non-sticky) column alignment issues when resizing browser
First column header doesn't resize when window does.
👀 before 👀
3.mp4
👀 after 👀
7.mp4
**3) Fixed first sticky header misalignment **
First column is out of place when you load the page and scroll down
👀 before (watch the Name column) 👀
1.mp4
👀 after 👀
8.mp4
**4) Fix flickering scrollbar **
Scrollbar flickers when resizing window large->small. The issue here was that the width of
.ScrollBarContent
was set by--p-scroll-bar-content-width
, so when you resize smaller unless--p-scroll-bar-content-width
is set on a bare-metal resize event (i.e. not by a throttled/debounced function), the scrollbar will be larger than the content when you size the window down and will flicker. Fixed this by setting this width to 0 when resizing and only actually setting--p-scroll-bar-content-width
once resizing completes.👀 before 👀
4.mp4
👀 after 👀
9.mp4
**5) Fix sticky header not resizing smoothly **
Watch the upper right corner of the sticky header. As you resize, the width of the header goes out of shape with the rest of the card, this happens because the debounce period is at a slower framerate than it should be. Fix was to update to 60FPS (and converted to use
throttle
instead ofdebounce
withmaxWait
for clarity).👀 before (watch upper right corner of sticky header) 👀
5.mp4
👀 after 👀
10.mp4
**6) Performance stuff **
useCallback
instead ofuseMemo
, we really don't need to memoize anything for thisHow to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes