Commit fea820f
fix(iOS) - Prevent SwiftUI based
Summary:
When a `filter` style is passed to a `View`, it can shift the `View` by safe area insets if it overlaps a safe area edge. Filter style should not affect layout. Also fixes - #57642
Unset [safeAreaRegions](https://developer.apple.com/documentation/swiftui/uihostingcontroller/safearearegions) on the hosting controller to opt out of implicit safe area insets. Below iOS 16.4 `safeAreaRegions` does not exist so it requires Obj-C swizzling hack as noted here - #57643. Hence, proper fix requires gating the filter feature to iOS 16.4. We can mention it in the documentation on release.
## Changelog:
[IOS] [FIXED] - Fix views with a filter having their content offset by the safe area insets
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: #58349
Test Plan:
- Set `releaseLevel` to canary.
- Render `<View style={{width: 100, height: 100, backgroundColor:"red", filter:[{blur: 10}]}} />` in RNTester, make sure it renders on top of the screen.
- View renders as expected on first mount.
- Change height or width, it will shift the view by safe area inset. It requires layout update because RCTMountingManager calls `finalizeUpdates` before calling `mountChildComponentView`, so on first mount the hosting view has no window and its safe area insets are zero.
| Before | After |
| --- | --- |
| <img width="200" alt="Filtered content pushed down by the top safe area inset" src="https://github.com/user-attachments/assets/49905f7b-0a82-4958-91d2-e89c852e5a93" /> | <img width="200" alt="Filtered content aligned with the view bounds" src="https://github.com/user-attachments/assets/85848179-43fc-42f4-9271-1093413ad42d" /> |
| Content is offset down and shrunk by the top inset | Content fills the view |
cc - jorge-cab
Reviewed By: christophpurrer
Differential Revision: D119153463
Pulled By: cipolleschi
fbshipit-source-id: edabd933b4928dd023109eba5d09b6447256615ffilter from insetting content by the safe area (#58349)1 parent 5dcbbae commit fea820f
2 files changed
Lines changed: 12 additions & 1 deletion
File tree
- packages/react-native
- ReactApple/RCTSwiftUI
- React/Fabric/Mounting/ComponentViews/View
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1746 | 1746 | | |
1747 | 1747 | | |
1748 | 1748 | | |
1749 | | - | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1750 | 1756 | | |
1751 | 1757 | | |
1752 | 1758 | | |
| |||
1755 | 1761 | | |
1756 | 1762 | | |
1757 | 1763 | | |
| 1764 | + | |
1758 | 1765 | | |
1759 | 1766 | | |
1760 | 1767 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
0 commit comments