-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Fix Text component padding touch area on iOS (Fabric) #54064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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 facebook#54056
Hi @ANTI-Tony! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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 facebook#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
I ve add those 2 test cases |
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
inRCTTextLayoutManager.mm
to fix overly strict hit testing logic.The previous implementation rejected touch points where
fraction == 0
orfraction == 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
Before: Only text content was clickable
After: Both padding and text content are clickable
Platforms
Changelog
[IOS][FIXED] - Fix Text component padding touch area on iOS with Fabric enabled