Skip to content

TreeView: Preserve expanded state of nested items - #2538

Merged
colebemis merged 15 commits into
mainfrom
treeview-persist-expanded-state
Nov 10, 2022
Merged

TreeView: Preserve expanded state of nested items#2538
colebemis merged 15 commits into
mainfrom
treeview-persist-expanded-state

Conversation

@colebemis

@colebemiscolebemis commented Nov 5, 2022

Copy link
Copy Markdown
Contributor

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

changeset-botBot commented Nov 5, 2022

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactPatch

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

github-actionsBot commented Nov 5, 2022

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
dist/browser.esm.js78.89 KB (0%)
dist/browser.umd.js79.54 KB (0%)

@colebemis
colebemis temporarily deployed to github-pages November 5, 2022 04:31 Inactive
Comment threadsrc/TreeView/TreeView.tsx Outdated
Comment threadsrc/hooks/useControllableState.ts Outdated
@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
@colebemiscolebemis changed the title TreeView: Persist expanded state of nested itemsTreeView: Preserve expanded state of nested itemsNov 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, joshblack and siddharthkp and removed request for siddharthkpNovember 8, 2022 04:55
@colebemis
colebemis temporarily deployed to github-pages November 8, 2022 05:03 Inactive
Comment threadsrc/TreeView/TreeView.tsx Outdated
@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 mainNov 10, 2022
@colebemis
colebemis deleted the treeview-persist-expanded-state branch November 10, 2022 14:32
@primer-cssprimer-css mentioned this pull request Nov 10, 2022
Sign up for freeto 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.

2 participants

@colebemis@joshblack