Skip to content

Commit cd2a327

Browse files
fix(android): a screen detached by a resize keeps its size
A Fabric mount that resizes a container and changes its screens applies the resize first. The container laid out the screen about to leave at the new size, which re-laid out its content for a size it was never shown at. When it came back after the container returned to its old size, its content was still laid out for the other size for a frame. When the container is resized outside a layout pass, it now applies its pending screen changes before laying out its screens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c719481 commit cd2a327

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎android/src/main/java/com/swmansion/rnscreens/legacy/ScreenContainer.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ open class ScreenContainer(
7373
r: Int,
7474
b: Int,
7575
) {
76+
// A Fabric mount resizes the container before its screen changes are applied. Applying them
77+
// first means a screen leaving in that mount is not resized, so its content keeps the size
78+
// it was laid out at and fits at once if it comes back. Never inside a layout pass.
79+
if (changed && !isInLayout) performUpdates()
7680
var i = 0
7781
val size = childCount
7882
while (i < size) {

0 commit comments

Comments
 (0)