Skip to content

Commit

Permalink
fix(ios): prevent layout in viewSafeAreaInsetsDidChange until first v…
Browse files Browse the repository at this point in the history
…iewDidLayoutSubviews (#10151)
  • Loading branch information
edusperoni committed Jan 3, 2023
1 parent ed3fe97 commit 760bbd0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/ui/page/index.ios.ts
Expand Up @@ -74,6 +74,7 @@ class UIViewControllerImpl extends UIViewController {

public isBackstackSkipped: boolean;
public isBackstackCleared: boolean;
private didFirstLayout: boolean;
// this is initialized in initWithOwner since the constructor doesn't run on native classes
private _isRunningLayout: number;
private get isRunningLayout() {
Expand All @@ -84,6 +85,7 @@ class UIViewControllerImpl extends UIViewController {
}
private finishRunningLayout() {
this._isRunningLayout--;
this.didFirstLayout = true;
}
private runLayout(cb: () => void) {
try {
Expand All @@ -98,6 +100,7 @@ class UIViewControllerImpl extends UIViewController {
const controller = <UIViewControllerImpl>UIViewControllerImpl.new();
controller._owner = owner;
controller._isRunningLayout = 0;
controller.didFirstLayout = false;

return controller;
}
Expand Down Expand Up @@ -125,7 +128,7 @@ class UIViewControllerImpl extends UIViewController {
const isBack = isBackNavigationTo(owner, newEntry);
owner.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
}

if (frame) {
if (!owner.parent) {
owner._frame = frame;
Expand Down Expand Up @@ -276,7 +279,7 @@ class UIViewControllerImpl extends UIViewController {

public viewSafeAreaInsetsDidChange(): void {
super.viewSafeAreaInsetsDidChange();
if (this.isRunningLayout) {
if (this.isRunningLayout || !this.didFirstLayout) {
return;
}
const owner = this._owner?.deref();
Expand Down

0 comments on commit 760bbd0

Please sign in to comment.