Enclosed is a screenshot of the issue. I've seen it moslty with lowest-level titles, but have not tested further.
For the screenshot, I've first create the top tree titles with typing #. After that, I pasted some text, and then selected some parts and clicked the H4 button. The last action resulted in the title not showing correct.
I've also had the issue if I typed the 4 #'s.
Details: Windows 10 version 21H1, Google Chrome 96.0.4664.45