-
Notifications
You must be signed in to change notification settings - Fork 536
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
TreeView: Performance improvements #2523
Conversation
…eeview-scroll-fix
🦋 Changeset detectedLatest commit: 438d653 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
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.
Looking great! 🥳
src/TreeView/TreeView.tsx
Outdated
} | ||
} | ||
|
||
.TreeView-item-container { |
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.
should we use [data-component]
here instead to keep it future proof?
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.
Ideally, I'd like these names to be entirely private. In other words, I'm not ready to commit to the naming and "future proof" them. I've updated the code comment to clarify this and prefixed all classnames with PRIVATE_
* Prevent focus event from bubbling to parent items * Update scroll story * Create violet-plants-sip.md * Ignore lint error * Update stress test * Lift styles to root * Remove unused imports * Remove unused sx prop * Clean up styles * Create tidy-olives-know.md * Update warning and prefix classnames with PRIVATE_ * Replace VisuallyHidden styled-component * Use VisuallyHidden component for root level live region * Update warning * Style directory icon without styled-components * Remove sx prop from item * Disable chromatic on TreeView stress test
Before
Opening a directory with 1000 files took 1.22s:
CleanShot.2022-11-02.at.16.36.13.mp4
After
Opening a directory with 1000 files now takes 590ms:
CleanShot.2022-11-02.at.16.38.20.mp4
Side-by-side
final_6362e660dbe31d0025fa3cd4_354575.mp4
Approach
To achieve these performance improvements, I moved the styles for tree items to the root level to avoid recomputing styles every time the tree updates. This is a temporary fix to enable the Repos team to use the TreeView component. We will need a system-level fix for styled-components performance soon. Writing performant components should be easy by default, and not require performance optimizations like this.
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.