Skip to content

fix: iOS hitTest should not check fill area when fill is none (#1256)#2972

Open
MuhammadSuleman97 wants to merge 1 commit into
software-mansion:mainfrom
MuhammadSuleman97:fix/ios-path-hit-test-stroke-only
Open

fix: iOS hitTest should not check fill area when fill is none (#1256)#2972
MuhammadSuleman97 wants to merge 1 commit into
software-mansion:mainfrom
MuhammadSuleman97:fix/ios-path-hit-test-stroke-only

Conversation

@MuhammadSuleman97

Copy link
Copy Markdown

Summary

Fixes #1256 — iOS: onPress not working correctly on SVG Path with fill="none" and only a visible stroke.

Problem

When a <Path> has fill="none" and only a visible stroke, the hitTest method 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 was used regardless of whether there was actually a fill.

Before: The hit test checked all three areas (fill, stroke, marker) unconditionally:

if (!CGPathContainsPoint(_hitArea, nil, transformed, evenodd) &&
    !CGPathContainsPoint(self.strokePath, nil, transformed, NO) &&
    !CGPathContainsPoint(self.markerPath, nil, transformed, NO)) {
    return nil;
}

After: Each area is only checked if the corresponding property is set:

BOOL inFillArea = self.fill != nil && _hitArea && CGPathContainsPoint(_hitArea, nil, transformed, evenodd);
BOOL inStrokeArea = self.stroke != nil && self.strokePath && CGPathContainsPoint(self.strokePath, nil, transformed, NO);
BOOL inMarkerArea = self.markerPath && CGPathContainsPoint(self.markerPath, nil, transformed, NO);

if (!inFillArea && !inStrokeArea && !inMarkerArea) {
    return nil;
}

Test Plan

  1. Create a <Path> with fill="none", a visible stroke, and an onPress handler
  2. Tap on the stroked line on iOS — onPress should fire consistently
  3. Verify that elements with only a fill (no stroke) continue to work as before
  4. Verify that elements with both fill and stroke are touchable in both areas

Related

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
Copilot AI review requested due to automatic review settings June 6, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CGPathContainsPoint condition into inFillArea, inStrokeArea, and inMarkerArea checks.
  • Guard CGPathContainsPoint calls with presence checks for fill/stroke and their corresponding paths.
  • Minor formatting fix at the file end (@end alignment).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: onPress is not working on the SVG Path

2 participants