fix: iOS hitTest should not check fill area when fill is none (#1256)#2972
Open
MuhammadSuleman97 wants to merge 1 commit into
Open
Conversation
When a Path has fill='none' and only a stroke, the hitTest on iOS was still checking _hitArea (the fill path) alongside strokePath. This caused inconsistent onPress behavior — touches on the stroke were sometimes missed because the fill-area check interfered. Now hitTest only considers fill area when self.fill is non-nil, only considers stroke area when self.stroke is non-nil and strokePath exists, and only considers marker area when markerPath exists. Fixes software-mansion#1256
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refines hit-testing for RNSVGRenderable by explicitly checking whether fill/stroke/marker paths and paints exist before calling CGPathContainsPoint, improving correctness when certain paints are unset and avoiding passing NULL paths.
Changes:
- Split the compound
CGPathContainsPointcondition intoinFillArea,inStrokeArea, andinMarkerAreachecks. - Guard
CGPathContainsPointcalls with presence checks for fill/stroke and their corresponding paths. - Minor formatting fix at the file end (
@endalignment).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Fixes #1256 — iOS:
onPressnot working correctly on SVG Path withfill="none"and only a visible stroke.Problem
When a
<Path>hasfill="none"and only a visible stroke, thehitTestmethod on iOS was still checking_hitArea(the fill path) alongsidestrokePath. This caused inconsistentonPressbehavior — touches on the stroke were sometimes missed because the fill-area check was used regardless of whether there was actually a fill.Before: The hit test checked all three areas (fill, stroke, marker) unconditionally:
After: Each area is only checked if the corresponding property is set:
Test Plan
<Path>withfill="none", a visiblestroke, and anonPresshandleronPressshould fire consistentlyRelated