-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 does not forward ref #3498
Comments
Are you able to forward ref to |
Here is a stack blitz: https://stackblitz.com/edit/stackblitz-starters-yxjqtp?file=app%2Fpage.tsx Not sure why it fails to render the accordion (rendering a button works), but I don't care about what it renders. The issue is that |
This is an issue with the underlying aria component library, as their SelectItem component does not expose ref for some reason, unlike the ListboxItem which does. |
I see. Was it reported by someone from nextui team to the aria team? |
@AnthonyPaulO any news on this? I've seen that the AccordionItem is using a button, so not sue what |
AccordionItem itself is a SelectItem behind the scenes, which is an Adobe Aria library component, and it does not expose a ref property. I'm not really a maintainer here so I don't have any relationship with the Aria team, but I guess I could post it as an issue on their site. I'll do that. |
Thanks, as you have more insights into how it works! 🙏🏻 |
I created the issue here: adobe/react-spectrum#6949 |
Okay never mind, I must have confused this with another issue so I closed the adobe react issue I created. After a lot of digging and debugging, the real cause of the ref not working is that it's being wiped out in the useTreeState call in use-accordion.ts. Apparently the Accordion's children are cloned and passed into useTreeState and become a managed collection. This collection is then iterated over to create the individual AccordionItem elements, but the ref of each child in the collection had been stripped out during the useTreeState call so it never gets passed on. This also occurs in ListBox via the useListState call, so those children can't have refs either, and a quick check shows it's not even implemented though it would be a quick thing to do. I presume all other components with children that use React Stately useXXXState methods suffer from the same ref-stripping issues. |
I don't think One of these is likely missing passing the ref along:
Feel free to have a look through our source for more ideas. |
@AnthonyPaulO any news on this one? |
NextUI Version
@nextui-org/[email protected]
Describe the bug
Accordion item won't accept a
ref
prop.Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
ref
prop toAccordionItem
will result in ref not being passed to theAccordionItem
since it does not support it.Expected behavior
AccordionItem
should accept theref
prop.Screenshots or Videos
No response
Operating System Version
Windows
Browser
Chrome
The text was updated successfully, but these errors were encountered: