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

TreeView: Performance improvements #2523

Merged
merged 21 commits into from
Nov 3, 2022
Merged

TreeView: Performance improvements #2523

merged 21 commits into from
Nov 3, 2022

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Nov 2, 2022

Before

Opening a directory with 1000 files took 1.22s:

CleanShot 2022-11-02 at 16 35 08@2x

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 37 39@2x

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

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Nov 2, 2022

🦋 Changeset detected

Latest commit: 438d653

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 78.87 KB (0%)
dist/browser.umd.js 79.51 KB (0%)

@colebemis colebemis temporarily deployed to github-pages November 2, 2022 21:28 Inactive
@colebemis colebemis added the component: TreeView Issues related to the TreeView component label Nov 2, 2022
@colebemis colebemis temporarily deployed to github-pages November 2, 2022 21:39 Inactive
@colebemis colebemis temporarily deployed to github-pages November 2, 2022 23:37 Inactive
@colebemis colebemis marked this pull request as ready for review November 2, 2022 23:43
@colebemis colebemis requested a review from a team November 2, 2022 23:43
@colebemis colebemis temporarily deployed to github-pages November 2, 2022 23:48 Inactive
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Looking great! 🥳

}
}

.TreeView-item-container {
Copy link
Member

@siddharthkp siddharthkp Nov 3, 2022

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?

Copy link
Contributor Author

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_

@colebemis colebemis temporarily deployed to github-pages November 3, 2022 17:58 Inactive
@colebemis colebemis temporarily deployed to github-pages November 3, 2022 19:11 Inactive
@colebemis colebemis temporarily deployed to github-pages November 3, 2022 19:28 Inactive
@colebemis colebemis temporarily deployed to github-pages November 3, 2022 23:04 Inactive
@colebemis colebemis merged commit 50ed644 into main Nov 3, 2022
@colebemis colebemis deleted the treeview-perf branch November 3, 2022 23:08
@primer-css primer-css mentioned this pull request Nov 3, 2022
broccolinisoup pushed a commit that referenced this pull request Nov 3, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TreeView Issues related to the TreeView component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants