feat: Support :hover and :active on SVG elements#9879
Draft
MatiPl01 wants to merge 6 commits into
Draft
Conversation
3342ada to
df014ea
Compare
4d5bfb2 to
81e9003
Compare
df014ea to
a5819d9
Compare
81e9003 to
e37cbc6
Compare
a5819d9 to
e222b3e
Compare
e37cbc6 to
e80db20
Compare
This was referenced Jul 9, 2026
Route the pointer (mouse/stylus) hover listener onto the touch host so svg elements, virtual children drawn on a shared SvgView canvas, receive hover at all. Gate the pointer reconcile to real enter/leave edges and beyond-slop moves so the canvas-wide hover-move flood can neither clobber a touch-set sticky hover nor flicker against the RNSVG re-render hit-test quirk. Fold the focus and press selector attaches, track each host's gesture in one map, and trim the coordinator and manager comments.
The :active/:active-deepest set was seeded from a per-view OnTouchListener on the touch host. A compound host such as an SvgView intermittently never delivers ACTION_DOWN to that listener on a real finger, so :active mostly never set. Drive the whole press from the per-window observer instead: it sees every event and hit-tests the down geometrically via reactTagForTouch, which does not depend on touch delivery. The per-view listener stays as the pre-0.86 / unobserved-window fallback.
e80db20 to
5fe485b
Compare
:hover and :active` on SVG elements
:hover and :active` on SVG elements:hover and :active on SVG elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds pointer
:hoverfor react-native-svg, and makes overlapping SVG shapes resolve:hover/:activeto the front-most one (they share oneSvgViewcanvas, so the topmost shape wins). Also fixes touch:activeon SVG on Android, where the per-view listener could missACTION_DOWNon a real finger; the press now comes from the window touch observer instead.Demo
:hoveron overlapping circles (the front one wins in the overlap):svg-hover-showcase.mp4
:activeon an SVG circle (press darkens it, dragging past the slop reverts):svg-active-showcase.mp4
Same taps, base vs this PR - on the base the touch is missed and nothing reacts:
svg-hover-before-after.mp4
Example source (drop-in
EmptyExample.tsx)