Skip to content

Conversation

@kkafar
Copy link
Member

@kkafar kkafar commented Oct 27, 2025

Description

Closes https://github.com/software-mansion/react-native-screens-labs/issues/531

This PR filters out calls to updateLayoutMetrics:oldLayoutMetrics: for modal screen.

This is done to prevent exactly the same issue we have with native
header. Basically e.g. on iPads, the horizontal space available is
constrained (the modal view is narrower than the view underneath) and
the native layout differs from first Yoga layout leading to content
jumps & flickers in the very beginning, before we send first state
updates.

I filter these out now. Relying fully on native layout. Really hard to
state whether it won't break anything. Until now manual testing indicates that the change
is ok.

Code remarks

I've put the code into - [RNSScreenView updateLayoutMetrics:oldLayoutMetrics:] and not into
- [RNSModalScreen updateLayoutMetrics:oldLayoutMetrics:] deliberately. We're not extending the RNSScreenView behaviour. We alter it. We can not omit calling super in - [RNSModalScreen updateLayoutMetrics:oldLayoutMetrics:] as we'd fail to update state gathered there on every call, potentially reintroducing #1463. Therefore I decided to handle this special case of subclass related code in superclass. What we could do here is to treat these as separate components & make them separate (do not inherit). This is something that we plan to do in next major, therefore decided against such big change here.

Changes

  • Initial reproduction
  • Filter out setting frame from RN for modals

Before

repro.mov

Notice this frame and the lack of green bar on the right side:
image

After

fix.mov

Test code and steps to reproduce

Checklist

This is done to prevent exactly the same issue we have with native
header. Basically e.g. on iPads, the horizontal space available is
constrained (the modal view is narrower than the view underneath) and
the native layout differs from first Yoga layout leading to content
jumps & flickers in the very beginning, before we send first state
updates.

I filter these out now. Relying fully on native layout. Really hard to
state whether it won't break anything. Until now manual testing seems
ok.
@kkafar kkafar marked this pull request as draft October 27, 2025 12:35
@kkafar kkafar requested review from kligarski, kmichalikk and t0maboro and removed request for t0maboro October 27, 2025 12:57
@kkafar kkafar marked this pull request as ready for review October 27, 2025 12:57
export { default as TestScreenStack } from './TestScreenStack';
export { default as TestSplitView } from './TestSplitView';
export { default as TestSafeAreaViewIOS } from './TestSafeAreaViewIOS';
export { default as Test3345 } from './Test3345';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I'd move this a few lines above, closer to other numbered tests.

if (parentVC == nil && [self isKindOfClass:RNSModalScreen.class]) {
// If we're in modal presentation, we don't want to set the frame from RN,
// as the available space is most likely restriced & differs from what Yoga
// resolves during firt layout. We want to rely on native layout here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// resolves during firt layout. We want to rely on native layout here.
// resolves during first layout. We want to rely on native layout here.


if (parentVC == nil && [self isKindOfClass:RNSModalScreen.class]) {
// If we're in modal presentation, we don't want to set the frame from RN,
// as the available space is most likely restriced & differs from what Yoga
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// as the available space is most likely restriced & differs from what Yoga
// as the available space is most likely restricted & differs from what Yoga

@kkafar
Copy link
Member Author

kkafar commented Nov 4, 2025

The problem is still reproducible when using very specific styles on scrollview. Added reproduction in ad8eda8

Screen.Recording.2025-11-04.at.11.42.25.mov

@kkafar kkafar marked this pull request as draft November 4, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants