The collapse animation does not support pre-determining the height of the wrapped elements. If the height of the wrapped elements is not determined and coded into the applied styles, then you are transitioning to/from height:auto; which doesn't work well because it is not supported to transition to/from this value by the css standard.
https://css-tricks.com/using-css-transitions-auto-dimensions/