shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
62.84k stars 3.53k forks source link

[bug]: No accordion animation when `value` is controlled via state #3908

Open Yumat10 opened 4 weeks ago

Yumat10 commented 4 weeks ago

Describe the bug

When making the accordion controlled, the opening/closing animation doesn't seem to occur.

Affected component/components

Accordion

How to reproduce

  1. Add an accordion component
  2. Make the type multiple
  3. Add state to control the value prop of the accordion
  4. Set value={state} and onValueChange={setState}
  5. Create a function to modify the value (ex. collapseAll and expandAll)
  6. Add a button to trigger the function from step 5
  7. Click on the button

On my end, the accordion-up and accordion-down animations are not longer taking place when making the accordion controlled via state.

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Chrome/Arc

Before submitting

eliuAtFanatics commented 6 days ago

Any updates on resolving this? I'm having some problems as well with accordions closing programmatically. I have a useEffect hook checking for external control. I see the function setting my values correctly, but the accordion just won't close.