[SwiftUI] 'onHover' is called on views overlayered on a ZStack

Number:rdar://9010301 Date Originated:2021-02-18
Status:Open Resolved:No
Product:SwiftUI Product Version:-
Classification:Incorrect/Unexpected Behavior Reproducible:Yes
When rendering a ZStack, if any Views with a lower `zIndex` than its siblings applies an `onHover` modifier, that closure gets called even if the View is overlayed (and potentially hidden) by other Views.

Steps to reproduce:
This is enough to exemplify the behavior:
ZStack {
        .onHover { active in
            if active {
                fatalError("Shouldn't be hoverable [\(active)]")


What did you expect to happen?
The `onHover` closure shouldn't have been called (specially receiving `true` in the argument) since the view is being covered and, therefore, not actually being hovered.

What actually happened?
The closure still get's called and receives `true` and the mouse pointer enters the view's bounds.



Check https://github.com/fjcaetano/not-awesome-swiftui

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!