Fix outdated viewport offset on Fabric surface (#37020)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37020

changelog: [internal]

if host view's position on screen changes, `RootShadowNode` has to be notified of this. Otherwise the state of UI is not correctly reflected in ShadowTree, leading to inconsistencies. For example, when trying to get views position in window, it won't be correct when hosting view isn't full screen.
Overriding `setFrame` only works for cases where it is hosting view's parent changing its position. But there are other cases where the position may change on the screen, like when hosting view's parent is moved by movable navigation bar. This does not affect frame of hosting view but it does change its position on the screen. To know about this event, we need to override `layoutSubviews`. `layoutSubviews` is called by UIKit whenever its internal flag `_needsLayout` is set to YES.

Reviewed By: javache

Differential Revision: D45122502

fbshipit-source-id: b7b1b08a8b3accffce7e3c71f7d19887caf6462f
This commit is contained in:
Samuel Susla
2023-04-21 10:43:17 -07:00
committed by Facebook GitHub Bot
parent 516642c101
commit 81d8992ceb
@@ -74,9 +74,9 @@ RCT_NOT_IMPLEMENTED(-(nullable instancetype)initWithCoder : (NSCoder *)coder)
[_surface stop];
}
- (void)setFrame:(CGRect)frame
- (void)layoutSubviews
{
[super setFrame:frame];
[super layoutSubviews];
CGSize minimumSize;
CGSize maximumSize;