-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: remove flicker in AccordionItem (#9818) #14776
fix: remove flicker in AccordionItem (#9818) #14776
Conversation
✅ Deploy Preview for v11-carbon-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Nice catch @tw15egan! You're absolutely right, I have updated the previous commit, this is how the tests are running And this is how it's working now: |
@cesardlinx unfortunately, this change removed the entire collapsing animation. I believe the animation itself may need to be reworked, and not rely on |
@tw15egan Yep! that's right. Let me elaborate more on why. Basically the main issue is that the collapsing animation is not actually "collapsing", instead it's "shrinking" as you can see here: So, the hacky trick that somebody used is to mixed the shrinking with the "display: none" in order to create the "collapsing" effect like this: And that's why you experience it like a small flickering when it collapses, because it's the combination of "shrinking" and then using "display: none". So what I did was to use only "display: none" in order to avoid the flickering. |
@cesardlinx the preferred solution would be to retain the animation and remove the flicker. The animation itself may need to be reworked. |
@tw15egan I can rework the animation, but I don't think I can access it am I right? |
Great, if you are interested in trying to fix the animation, it is located in |
Nice! so cool, I thought that you were using an external package or something, that's great!! I'll fix it then :D |
@tw15egan Animation reworked! This is how it works now: I'm getting some snapshot errors though as you can see here: Should I update the snapshots? Please let me know |
Hey @tw15egan any updates on this? were you able to verify how the animation is working now? |
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.
I don't see the flicker anymore but have a few concerns below.
33095fd
to
7c32a37
Compare
Hey @tay1orjones. I've addressed all the issues you mentioned earlier. I would greatly appreciate your feedback when you have the time. Please take a look at my comments on changing the markup. I explain why we should add a wrapper around the accordion content. |
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.
Thanks for making all those changes! I'm sorry for such a delay in reviewing. This is looking good, I have just two small comments after re-reviewing.
const toggleElement = event.target; | ||
|
||
let content = toggleElement.nextElementSibling; | ||
|
||
// when toggle element is not the button | ||
if (toggleElement.nodeName !== 'BUTTON') { | ||
content = toggleElement.parentElement.nextElementSibling; | ||
} |
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.
Gaining access to the content node this way feels brittle. Instead, could a ref be placed on the div
containing the children
, and then that contentRef.current.style
be used in the maxBlockSize
logic below?
content = toggleElement.parentElement.nextElementSibling; | ||
} | ||
|
||
if (content.style.maxBlockSize) { |
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.
Would it make more sense to use isOpen
here?
Also snapshots need to be updated, just run |
Removes the flickering effect when using AccordionItem as a controlled component
60fb9be
to
0d30252
Compare
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.
Thanks for addressing that feedback. I don't see the flicker in the storybook example. Removing the test story after a second approval and before merging would be good 👍
Awesome! Thank you @tay1orjones for all the feedback, I will remove the test story after second approval 👍 |
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.
looks good! @cesardlinx
Thank you @andreancardona I have removed the test story as @tay1orjones suggested 🙂 |
448c0ef
Hey there! v11.44.0 was just released that references this issue/PR. |
…bon-design-system#14776) * fix: remove flicker in AccordionItem (carbon-design-system#9818) Removes the flickering effect when using AccordionItem as a controlled component * fix: rework accordion component animation (carbon-design-system#9818) * refactor: use ref hook for accordion content * test: update accordion component snapshots * docs: fix extra missing curly brace in .all-contributorsrc * docs: remove accordion controlled test story --------- Co-authored-by: Andrea N. Cardona <cardona.n.andrea@gmail.com> Co-authored-by: Alison Joseph <alison.joseph@us.ibm.com>
Removes the flickering effect when using AccordionItem as a controlled component
Closes #9818
Changelog
Changed
Removed
Testing / Reviewing
Here you can see how it was working before:
And this is how it is working now: