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: Preserve expanded state of nested items #2538

Merged
merged 15 commits into from
Nov 10, 2022

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Nov 5, 2022

As requested by @jsholes in his a11y sign-off review, this PR persists the expanded state of nested tree items when their parent is collapsed/expanded.

In some instances, the tree view seems to reset the expanded/collapsed state of descendant nodes when a parent's state is changed.
Expanding or collapsing a parent node must not have an impact on the state of any of its descendants. I.e. if a descendent is collapsed, it should stay collapsed even if the parent is collapsed and then expanded again, and vice versa.

Before

CleanShot.2022-11-07.at.20.47.01.mp4

After

CleanShot.2022-11-07.at.20.47.48.mp4

Breaking changes

To implement this change, I had to introduce a required id prop for all TreeView.Items.

- <TreeView.Item>...
+ <TreeView.Item id="unique-id">...

Merge checklist

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

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2022

🦋 Changeset detected

Latest commit: 2d19b1e

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 5, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 78.89 KB (0%)
dist/browser.umd.js 79.54 KB (0%)

@colebemis colebemis temporarily deployed to github-pages November 5, 2022 04:31 Inactive
src/TreeView/TreeView.tsx Outdated Show resolved Hide resolved
@colebemis colebemis temporarily deployed to github-pages November 7, 2022 20:35 Inactive
@colebemis colebemis temporarily deployed to github-pages November 8, 2022 04:39 Inactive
@colebemis colebemis changed the title TreeView: Persist expanded state of nested items TreeView: Preserve expanded state of nested items Nov 8, 2022
…t-expanded-state' of github.com:primer/react into treeview-persist-expanded-state
@colebemis colebemis marked this pull request as ready for review November 8, 2022 04:55
@colebemis colebemis requested review from a team, siddharthkp and joshblack and removed request for siddharthkp November 8, 2022 04:55
@colebemis colebemis temporarily deployed to github-pages November 8, 2022 05:03 Inactive
src/TreeView/TreeView.tsx Outdated Show resolved Hide resolved
@colebemis colebemis temporarily deployed to github-pages November 9, 2022 13:54 Inactive
@colebemis colebemis temporarily deployed to github-pages November 10, 2022 14:30 Inactive
@colebemis colebemis merged commit bdbccaa into main Nov 10, 2022
@colebemis colebemis deleted the treeview-persist-expanded-state branch November 10, 2022 14:32
@primer-css primer-css mentioned this pull request Nov 10, 2022
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.

None yet

2 participants