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

fix(TreeView): Fix invalid tree item children #1584

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Conversation

silvalaura
Copy link
Collaborator

@silvalaura silvalaura commented Nov 20, 2024

Issue: none

What I did

MAST engineers reported a change in behavior from 4.6.0 to our prerelease. Items that had invalid children would get the expandable arrow when they shouldn't. In addition, I added unit tests so we don't break this accidentally in the future.

Screenshots:

All examples with the same code:

   <TreeView>
        <TreeItem label="Node 0 - fragment" itemId="item0" testId="item0">
          <></>
        </TreeItem>
        <TreeItem label="Node 1" itemId="item1" testId="item1">
          <TreeItem label="Child 1" itemId="item-child1">
            <TreeItem label="Grandchild 1" itemId="item-gchild1">
              <Tag>This is a tag as a child of Grandchild 1</Tag>
            </TreeItem>
          </TreeItem>
        </TreeItem>
        <TreeItem label="Node 2" itemId="item2">
          <TreeItem label="Child 2" itemId="item-child2">
            <TreeItem label="Grandchild 2" itemId="item-gchild2">
              <TreeItem label="Great-grandchild 2" itemId="item-ggchild2" />
              <TreeItem label="Great-grandchild 3" itemId="item-ggchild3" />
            </TreeItem>
          </TreeItem>
        </TreeItem>
        <TreeItem label="Node 3" itemId="item3"></TreeItem>
        <TreeItem label="Node 4" itemId="item4">
          Child of node 4 is just text
        </TreeItem>
      </TreeView>

In 4.6.0
image

In 4.7.0-next.50
image

Update from this PR
image

Checklist

  • changeset has been added
  • Pull request description is descriptive
  • [-] I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works

How to test

Open CodeSandbox and try different kinds of tree structures. Ensure that the items that are expandable are the expected ones (ones with valid children, whether that's a single TreeItem or multiple).

Note: to test previous behavior, open CS and change the package version from 4.6.0 to the latest prerelease

@silvalaura silvalaura added bug blocks release High priority tickets that block next release labels Nov 20, 2024
@silvalaura silvalaura self-assigned this Nov 20, 2024
@silvalaura silvalaura requested a review from a team as a code owner November 20, 2024 19:40
Copy link

changeset-bot bot commented Nov 20, 2024

🦋 Changeset detected

Latest commit: dbfccb5

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

This PR includes changesets to release 1 package
Name Type
react-magma-dom 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

@silvalaura silvalaura added the ready for review Pull requests that are ready for developer review label Nov 20, 2024
Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Collaborator

@moathabuhamad-cengage moathabuhamad-cengage left a comment

Choose a reason for hiding this comment

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

works as intended, tested locally on /story/treeview--invalid-tree-items

@silvalaura silvalaura merged commit 46c70e6 into dev Nov 21, 2024
3 checks passed
@silvalaura silvalaura deleted the fix/treeViewValidity branch November 21, 2024 14:29
@silvalaura
Copy link
Collaborator Author

MAST engineers checked this version and are no longer seeing this visual issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocks release High priority tickets that block next release ready for review Pull requests that are ready for developer review
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants