I tried this both in Emacs 27.2 and Emacs 28, and I was unable to reproduce this bug. Are you still seeing this? If so, can you give a precise recipe for reproducing the bug, starting from "emacs -Q"? I am not seeing this on Emacs 28. It must have been fixed. Thank you for following up.