cengage / react-magma

https://react-magma.cengage.com
MIT License
21 stars 13 forks source link

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

Closed silvalaura closed 1 day ago

silvalaura commented 1 day ago

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

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

changeset-bot[bot] commented 1 day ago

🦋 Changeset detected

Latest commit: dbfccb50420fec7302e41774f646ff4e41fe17b0

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

github-actions[bot] commented 1 day ago

🚀 Deployed on https://docs-preview-1584--upbeat-sinoussi-f675aa.netlify.app

github-actions[bot] commented 1 day ago

🚀 Deployed on https://storybook-preview-1584--upbeat-sinoussi-f675aa.netlify.app

github-actions[bot] commented 1 day ago

🚀 Deployed on https://docs-preview-1584--upbeat-sinoussi-f675aa.netlify.app

github-actions[bot] commented 1 day ago

🚀 Deployed on https://storybook-preview-1584--upbeat-sinoussi-f675aa.netlify.app