If you use Apple Mail (Mail.app in macOS) in conjunction with one or more Gmail accounts, you may have experienced an issue where the app randomly becomes the key window. I consider this a very nasty bug because it is very disruptive. We use our computers to get work done. This is a bug that was introduced years ago and never got fixed.
I filed a radar (41445230) (now feedback FB5721269) in June 2018.
The status is still showing Recent Similar Reports: None, Resolution: Open.
MacRumors wrote an article on this issue today, quoting a blog post by Philipp Defner. There is a lot to say about Apple's software quality and attitude towards fixing bugs in recent years. Apple is working hard on platform conformance which might make it easier to maintain its software going forward.