x-collapse plugin rendering issue on children components #4437
-
Lets say you render a parent element and a child element. Both parent and children can be displayed or hidden, therefore you use the You want the parent to close the children if it gets closed, therefore when the parent closes it emits an event for all children to close. The issue comes with the way the children is being displayed. If you use a standard If you use I've replicated this behaviour inside of this codepen: https://codepen.io/kiriamcf-revo/pen/NWQVWBP As a side note, from what I've tested, animation durations do not have any effect on this. The way I've encountered this issue is by having a dropdown with collapsable items inside. When the dropdown is closed I want to reset all the collapsed children and then the issue happens. Maybe I am not using I've checked x-collapse-bug.mov |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think the code is more complex than it should be: <div x-data="{showParent: false}">
<button type="button" x-on:click="showParent = !showParent">Display parent</button>
<div x-show="showParent"
x-cloak
x-data="{showChildren: false}"
x-transition.opacity.duration.300
x-effect="if (showParent == false) $nextTick(() => showChildren = false)">
Parent component
<button type="button" x-on:click="showChildren = !showChildren">Display children</button>
<div x-show="showChildren" x-cloak x-collapse.duration.300>
Children component
</div>
</div>
</div> |
Beta Was this translation helpful? Give feedback.
I think the code is more complex than it should be: