[@expo/ui] feat[iOS] Added contentShape() modifier for SwiftUI#42813
[@expo/ui] feat[iOS] Added contentShape() modifier for SwiftUI#42813intergalacticspacehighway merged 12 commits intoexpo:mainfrom
Conversation
|
Subscribed to pull request
Generated by CodeMention |
📝 WalkthroughWalkthroughImplements a new Changes
Sequence Diagram(s)Not applicable — changes represent a straightforward modifier registration and application pattern without complex multi-component interactions or non-trivial sequential flows. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/native-component-list/src/screens/UI/ModifiersScreen.ios.tsx`:
- Around line 719-724: The onTapGesture handler reads the stale
contentShapeButtonCounter and calls
setcontentShapeButtonCounter(contentShapeButtonCounter + 1), which can drop
rapid taps; switch to a functional state update in the onTapGesture handler (use
setcontentShapeButtonCounter(prev => prev + 1)) and compute the new count from
prev so the Alert uses the correct incremented value (e.g., call Alert.alert
with the nextCount derived inside the functional updater or invoke Alert from
within the updater closure using prev to build nextCount). This change affects
the onTapGesture callback and the setcontentShapeButtonCounter usage to ensure
increments and displayed counts never use stale state.
apps/native-component-list/src/screens/UI/ModifiersScreen.ios.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
apps/native-component-list/src/screens/UI/ModifiersScreen.ios.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: nishan (o^▽^o) <nishanbende@gmail.com>
intergalacticspacehighway
left a comment
There was a problem hiding this comment.
Thanks @sam-shubham for the PR.
One last thing: Can you regenerate the docs by running below command?
et gdad 'expo-ui/swift-ui/modifiers'
Done |
Done 👍 |
|
@sam-shubham Can you also fix the failing CI lint issues? |
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
|
Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines. I've found some issues in your pull request that should be addressed (click on them for more details) 👇
|
I tried to fixx all of them which were there can you have a look once.. |
|
hey @amandeepmittal @intergalacticspacehighway can you help m with the "ios unit test flow" failure in CI |
Fixes #42747
Why
SwiftUI’s
HStackinside aListdoes not respond to tap gestures when the user taps on empty space (for example, areas created bySpacer). This is a known SwiftUI behavior and is typically solved using.contentShape(Rectangle())in native SwiftUI.However,
@expo/ui/swift-uidid not expose acontentShapemodifier, making it impossible to implement this common and expected interaction pattern. As a result:TextorImageresponded to tapsThis PR adds first-class support for
contentShapein@expo/ui, aligning Expo’s SwiftUI layer with native SwiftUI capabilities.How
This PR introduces a new
contentShapemodifier across the full Expo UI stack.iOS (SwiftUI)
ContentShapeModifierimplemented as aViewModifierrectangleroundedRectanglecapsulecircleellipsecontentShape(...)APIViewModifierRegistryunder"contentShape"JavaScript / TypeScript
contentShapeto@expo/ui/swift-ui/modifiersclipShapeandcontainerShapeBuiltInModifiertypingDeveloper Experience
onTapGestureSpacer) participate in hit testingTest Plan
Manual Testing
HStack(withoutcontentShape)HStack(withcontentShape(rectangle()))Expected vs Actual
Textelements receive tap eventsScreen.Recording.2026-02-03.at.2.47.57.PM.mov
Checklist
changelog.mdentry and rebuilt the package sources according to the guidenpx expo prebuild& EAS BuildclipShapeandcontainerShapemodifiersSummary by CodeRabbit
contentShapemodifier to define interactive hit-test areas independent of visual boundaries, enabling more flexible touch responsiveness for UI elements.