-
Notifications
You must be signed in to change notification settings - Fork 158
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(TableOfContents): sync props and state for dynamically added items #7687
fix(TableOfContents): sync props and state for dynamically added items #7687
Conversation
Deploy preview created for package Built with commit: f2ea4218617daabc033e14fd4f0a7e42c0894141 |
Deploy preview created for package Built with commit: f2ea4218617daabc033e14fd4f0a7e42c0894141 |
Deploy preview created for package Built with commit: f2ea4218617daabc033e14fd4f0a7e42c0894141 |
Deploy preview created for package Built with commit: f2ea4218617daabc033e14fd4f0a7e42c0894141 |
Deploy preview created for package Built with commit: daaf2af8657c71367312f32f7db2fbf75f78119d |
Deploy preview created for package Built with commit: f2ea4218617daabc033e14fd4f0a7e42c0894141 |
Deploy preview created for package Built with commit: f2ea4218617daabc033e14fd4f0a7e42c0894141 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
### Related Ticket(s) #5644 ### Description This PR updates the web components, React wrapper, and React storybook Table of Contents stories according to match the expected content described in #5644: * only "Default" (vertical) and "Horizontal" stories remain * "With heading content" knob in default story toggles a link list header instead of an image * the number of items is limited from 4-8 and the copy can be customized. This does not work properly in the web components storybook UI so you will need to view the story in a separate tab. This will work in the React storybook after #7687 is merged ### Changelog **New** - dynamic content knobs (the table of contents component does not update when its child elements change though, need to view story in new tab for updates) - "Horizontal" story in React - "Default" story in React **Changed** - "Default" story in web components and react wrapper **Removed** - obsolete React stories - "With heading content" stories in all storybooks
Related Ticket(s)
#7676
Description
This PR updates the React TableOfContents so that when items are dynamically added by the ToC component a rerender is triggered. Previously when dynamically populating the ToC, it would remain in the same state as the initial render
this can be tested in the TableOfContents story from #7676 by adding additional items in the story knobs https://ibmdotcom-react.s3.us-south.cloud-object-storage.appdomain.cloud/deploy-previews/7676/index.html
Changelog
New
validateMenuItems
Changed
children
to update when ToC items are dynamically added/removed