carbon-design-system/carbon

[AccordionItem] extend to render contents when expanded/opened

Open

#5,901 opened on Apr 21, 2020

 (4 comments) (0 reactions) (0 assignees)JavaScript (1,733 forks)batch import
afrohackscomponent: accordionhacktoberfestneeds: community contributionproposal: opentype: enhancement 💡

Repository metrics

Stars
 (7,442 stars)
PR merge metrics
 (Avg merge 9d 14h) (106 merged PRs in 30d)

Description

Summary

I'd like to offer up a contribution that we made recently in https://github.com/IBM/carbon-addons-iot-react/pull/1105 , if the team is interested.

We've extended AccordionItem to include optional stateful logic to only render the contents on expand of the section.

Justification

Some consuming applications with a ton of content (think entire dashboards) see a perf hit when contents is always rendered irrespective of if the AccordionItem is closed.

Desired UX and success metrics

via a prop or composition, the accordion item can be configured to render content when expanded. Closing of the section should not unmount the contents, but preserve it.

Specific timeline issues / requests

n/a

Available extra resources

I can submit a PR if y'all are good with this idea 👍

Contributor guide