[Feature] Hover Priority
I would like a mechanism to query hover state when multiple elements are on top of each other. The implementation of Clay_PointerOver has a "TODO return priority for separating multiple results" so this is already being considered.
The primary question to me is the API mechanism. I prototyped two approaches leveraging userData:
-
Elements can specify an explicit hover priority. An element is hovered if it is in the pointerOverIds list and its priority is equal to the max priority of any element in the list.
-
Elements can indicate they care about hover results. This is equivalent to implicitly setting a priority based on the current element depth and using the previous approach.
If all elements have a priority of 0 then the system is equivalent to existing usage preserving backwards compatibility.
The difficulty with the first approach is that reusable widgets may not know how to set an explicit priority, so something that leverages element depth seems preferable. Always using depth does not work as non-interactible elements such as text can override hover state unexpectedly.
A more invasive change that might work is recording which elements have queried hover state and prioritize these based on element depth. Given the interest in externalizing Clay interactions, this doesn't seem like the best direction.