After some digging, I believe the issue is Wayland vs X11 in a virtual machine. When the display process is set to use Xorg, this issue is not visible. It reappears when it is set back to Wayland. It is not solved by installing xwayland either.