I am currently working on implementing a typing animation in React. The li
element has an animation that recursively changes its width from 0px
to 100%
. However, I have noticed that when the width of the li
changes, the parent ul
does not adjust its width accordingly, resulting in empty space in the text area. I would like the wrapper to shrink along with the li
animation.
I suspect the issue may be related to how I directly manipulated the content of the li
element using ref.current.contentText
, but I cannot be certain.
To provide a visual representation of the problem, I have created a demo where the empty space is highlighted in blue:
Demo: https://codesandbox.io/s/nostalgic-breeze-hq7d6e?file=/src/styles.css
If anyone has any insights into what might be causing this issue and how it can be resolved, I would greatly appreciate your help. Thank you.