Skip to content

Fix Text component padding touch area on iOS (Fabric) - #54064

Open
ANTI-Tony wants to merge 2 commits into
react:mainfrom
ANTI-Tony:fix-text-padding-press-event
Open

ANTI-Tony wants to merge 2 commits into
react:mainfrom
ANTI-Tony:fix-text-padding-press-event

Conversation

@ANTI-Tony

@ANTI-Tony ANTI-Tony commented Oct 4, 2025 •

Copy link
Copy Markdown

Summary

Fixes #54056

When a Text component has padding, onPress events were not triggered when clicking in the padding area on iOS with the new architecture (Fabric) enabled.

Changes

Modified getEventEmitterWithAttributeString in RCTTextLayoutManager.mm to fix overly strict hit testing logic.

The previous implementation rejected touch points where fraction == 0 or fraction == 1, which occurs when clicking in padding areas. This fix removes the fraction check and allows any valid character index within the text storage to return an event emitter.

Test Plan

  1. Create a Text component with padding and onPress handler
  2. Click on the padding area (not the text itself)
  3. Verify that onPress is triggered

Before: Only text content was clickable
After: Both padding and text content are clickable

Platforms

  • iOS (Fabric)
  • Android (not affected by this issue)

Changelog

[IOS][FIXED] - Fix Text component padding touch area on iOS with Fabric enabled

When a Text component has padding, onPress events were not triggered
when clicking in the padding area on iOS. This was caused by overly
strict hit testing logic in getEventEmitterWithAttributeString.

The previous logic rejected touch points where fraction == 0 or 1,
which occurs when clicking in padding areas. This fix removes the
fraction check and allows any valid character index within the text
storage to return an event emitter.

Fixes react#54056
@meta-cla

meta-cla Bot commented Oct 4, 2025

Copy link
Copy Markdown

Hi @ANTI-Tony!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@react-native-bot

react-native-bot commented Oct 4, 2025 •

Copy link
Copy Markdown
Collaborator
Fails
🚫

📋 Missing Changelog - Please add a Changelog to your PR description. See Changelog format

Generated by 🚫 dangerJS against ca8c79a

@meta-cla

meta-cla Bot commented Oct 4, 2025

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 4, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 4, 2025
@javache

javache commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

Could you add a test-case to RNTester to demonstrate this issue?

Could you also test what happens when the text view is flattened in a much bigger container. Are we definitely not receiving touches outside of the textview's bounds?

…ses to demonstrate the fix for react#54056:  1. Text with Padding - Touch Area Test: Shows that both padding and    text content are now clickable after the fix  2. Text Padding Boundary Test: Verifies that touches outside the text    view's bounds are not captured when nested in a larger container
@ANTI-Tony

Copy link
Copy Markdown
Author

I ve add those 2 test cases

@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label.

@react-native-bot react-native-bot added Stale There has been a lack of activity on this issue and it may be closed soon. and removed Stale There has been a lack of activity on this issue and it may be closed soon. labels Apr 10, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 8, 2026

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Padding on Text results in incorrect bounding box for press events

4 participants