They both have Raycast Target checked.
Here is a video of the mysterious behaviour:
First I open the context menu UI and move my pointer out to show the expected behavior. The menu closes when the pointer exits. Strangely the EventSystem says that the pointer is still over the context menu background image when OnPointerExit is called. (not in the video: I also checked the event data and can see the context menu image’s GameObject in the list of hovered GameObjects at that time as well) But whatever, it works.
I then show the code I am using on the same GameObject as the context menu’s background Image.
Next I mouse over a green image that is a descendant of the context menu’s GameObject and you can see that the context menu immediately closes. Now the EventSystem says that the pointer is NOT over the context menu background image when OnPointerExit is called.
Notice how I can move the pointer over other UI elements in the context menu without the menu closing (images, buttons, sliders) but if I move my pointer over that one green image then OnPointerExit is called on the context menu.
Then I pause play mode to examine the UI. I open up the items in the hierarchy. You can see two GameObjects in under the Bar Container GameObject. FilledBar is part of a prefab which is instantiated to populate the context menu. It has a white Image component with Raycast Target checked. Resource Row Promise Item(Clone) is also has an Image with Raycast Target checked but is green. It was created by the script that manages the Bar Container contents. Despite being nearly identical the white image does not cause the context menu to close but the green one does.
Does anyone have any ideas about the difference in behavior?