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

AccordionItem - feature to toggle isExpanded outside the component - possible Octoberfest item? #677

Closed
marmid74 opened this issue Oct 15, 2020 · 3 comments · Fixed by #722

Comments

@marmid74
Copy link

Is your feature request related to a problem? Please describe.

In our application we have an Accordion table which is default collapsed at initial render. However we want to toggle isExpanded when the user starts to fill in a filter search string.
Initial render:
image

Describe the solution you'd like

Render and set AccordionItem to isExpanded when entering a filter search string.
We wish to toggle "isExpanded" when user enters a filter search string.
image

Additional context

This feature could be suitable as an OctoberFest issue

@vnys
Copy link
Member

vnys commented Oct 15, 2020

Thanks for the feature request, being able to control the accordion from the outside from a query param or url segment has been discussed previously, so that’s another use case that would be solved by adding this feature. If it’s a good first issue is another discussion 😉 Would you be willing to have a look at it yourself if we make this a hacktober-issue?

@marmid74
Copy link
Author

Vi gjør et forsøk :-)

@imp-dance
Copy link

If I understand correctly, this can be solved by adding a useEffect to AccordionItem.jsx :

React.useEffect(() => {
   setExpanded(isExpanded)
}, [isExpanded]);

Which would allow users to programatically change the isExpanded-prop on demand.

This would be my first contribution, so if you guys think this is a decent solution then I can submit a pull request from my fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants