[ui][ios] - Add ignoreSafeAreaKeyboardInsets prop to Host#41302
[ui][ios] - Add ignoreSafeAreaKeyboardInsets prop to Host#41302intergalacticspacehighway merged 9 commits intomainfrom
ignoreSafeAreaKeyboardInsets prop to Host#41302Conversation
|
The Pull Request introduced fingerprint changes against the base commit: 80ffc01 Fingerprint diff[
{
"op": "changed",
"beforeSource": {
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoAutolinkingIos"
],
"hash": "e2a72efbe83f07203ad8fea8169e7c5a5071c412"
},
"afterSource": {
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoAutolinkingIos"
],
"hash": "8c150259cda0511d4fd81a698b97eac6d89f2282"
}
},
{
"op": "changed",
"beforeSource": {
"type": "dir",
"filePath": "../../packages/expo-ui/ios",
"reasons": [
"expoAutolinkingIos"
],
"hash": "c945f781ee51d418b9abfb15e9e71fd650a294b3"
},
"afterSource": {
"type": "dir",
"filePath": "../../packages/expo-ui/ios",
"reasons": [
"expoAutolinkingIos"
],
"hash": "8cc342f73b25a8e6f368759e9d09ac3f1ea03e0c"
}
}
]Generated by PR labeler 🤖 |
ignoreSafeAreaInsets prop to HostignoreKeyboardSafeAreaInsets prop to Host
ignoreKeyboardSafeAreaInsets prop to HostignoreSafeAreaKeyboardInsets prop to Host
|
Subscribed to pull request
Generated by CodeMention |
|
I had just upgraded to |
|
@vicovictor we'll be cherrypicking these changes in upcoming expo patch release. Can you stay on 0.2.0-beta.9 till then? |
# Why In some usecases we want to control the safe area insets in RN instead of allowing SwiftUI to handle it e.g. custom keyboard handling with keyboard controller library. Demo - https://exponent-internal.slack.com/archives/C08CCJ60467/p1764263300639479 Blogpost for supporting on iOS < 16.4 (it is a hack but works) - https://steipete.me/posts/2020/disabling-keyboard-avoidance-in-swiftui-uihostingcontroller This PR adds `ignoreSafeAreaKeyboardInsets` prop to Host. It is configurable per Host. When it is set, SwiftUI content will ignore safe area insets. <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> # How UIHostingController adds safe area insets for SwiftUI views. These insets are configurable for some Views using `ignoreSafeAreaInsets` modifier. But I noticed that TextField does not respect this modifier and will still show keyboard avoidance behaviour. UIHostingController has a configurable [property](https://developer.apple.com/documentation/swiftui/uihostingcontroller/safearearegions) to disable safe area insets for all the SwiftUI contents, which can be used for such TextField cases. However this property only works for iOS 16.4 and above. There are some hacks to support it in <16.4 [here](https://developer.apple.com/forums/thread/658432) and [here](https://gist.github.com/steipete/da72299613dcc91e8d729e48b4bb582c). We can maybe add that. <!-- How did you build this feature or fix this bug and why? --> # Test Plan Before/After. Added the repro in a new screen https://github.com/user-attachments/assets/552eb6e1-64db-4c45-9185-cdb8eb6b3986 https://github.com/user-attachments/assets/a625a5b4-5545-4edc-a654-2ac37642079e <!-- Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction. --> # Checklist <!-- Please check the appropriate items below if they apply to your diff. --> - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [x] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [x] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
I found the same error in expo 54.0.31 and expo/ui 0.2.0-beta.10 |
# Why `Host` adds safe area insets to SwiftUI views causing such issues - #42576. We had added [`ignoreSafeAreaKeyboardInsets`](#41302) for similar reasons but it was handling only keyboard insets. <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> # How Adds `ignoreSafeArea` prop to `Host` which can be used to ignore all insets as well as keyboard insets. <!-- How did you build this feature or fix this bug and why? --> # Test Plan Tested the repro shared in the reported [issue](#42576). It gets fixed on passing `ignoreSafeArea` prop to `Host` https://github.com/user-attachments/assets/17bfb493-07d1-455a-8f93-bc5d4bbcb92f <!-- Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction. --> # Checklist <!-- Please check the appropriate items below if they apply to your diff. --> - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [x] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [x] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
Why
In some usecases we want to control the safe area insets in RN instead of allowing SwiftUI to handle it e.g. custom keyboard handling with keyboard controller library. Demo - https://exponent-internal.slack.com/archives/C08CCJ60467/p1764263300639479
Blogpost for supporting on iOS < 16.4 (it is a hack but works) - https://steipete.me/posts/2020/disabling-keyboard-avoidance-in-swiftui-uihostingcontroller
This PR adds
ignoreSafeAreaKeyboardInsetsprop to Host. It is configurable per Host. When it is set, SwiftUI content will ignore safe area insets.How
UIHostingController adds safe area insets for SwiftUI views. These insets are configurable for some Views using
ignoreSafeAreaInsetsmodifier. But I noticed that TextField does not respect this modifier and will still show keyboard avoidance behaviour. UIHostingController has a configurable property to disable safe area insets for all the SwiftUI contents, which can be used for such TextField cases. However this property only works for iOS 16.4 and above. There are some hacks to support it in <16.4 here and here. We can maybe add that.Test Plan
Before/After. Added the repro in a new screen
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-28.at.23.35.52.mov
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-28.at.23.35.22.mov
Checklist
changelog.mdentry and rebuilt the package sources according to this short guidenpx expo prebuild& EAS Build (eg: updated a module plugin).