I suggest you restart the Mac in safe mode and see if the problem exists there as well.
Safe mode will often correct weird software behavior by forcing the OS to do disk repair, clear caches and other housekeeping and disables acceleration and third-party mods. When you're in safe boot, the machine won’t be at its best performance, especially with graphics, but that's expected.
How to use safe mode on your Mac - Apple Support
Does the same thing happen while in Safe mode?
You can exit safe mode by restarting your Mac normally.
You might also login to another user account on the Mac to see if the problem is the same with that user. You may have to create another user by going to System Settings > Users and Groups > Add account...
If the problem does not exist in the other user account, that indicates the problem is within your account and not necessarily the installed OS.