Skip to content

Conversation

kligarski
Copy link
Contributor

@kligarski kligarski commented Sep 5, 2025

Description

Fixes the workaround from #3111 on Paper.

On Paper, in debug mode, sometimes there are some views between RNSScreenView and RNSScreenContentWrapper. This has been an issue before: #2683.

To make the workaround work correctly, we look for RNSScreenContentWrapper in first descendant chain, when in debug mode on Paper.

Fixes https://github.com/software-mansion/react-native-screens-labs/issues/412.

Changes

  • look for RNSScreenContentWrapper in first descendant chain, when in debug mode on Paper

Test code and steps to reproduce

Run Test3111 on Paper in debug mode.

Checklist

Comment on lines +576 to +586
UIView *currentView = vc.view;
while (currentView != nil) {
if ([currentView isKindOfClass:RNSScreenContentWrapper.class]) {
contentWrapper = static_cast<RNSScreenContentWrapper *>(currentView);
break;
} else if ([currentView.subviews count] > 0) {
currentView = currentView.subviews[0];
} else {
break;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is similar to RNSScrollViewFinder, we could extract it to separate class but we would probably need to cast the result in places where we would use this function or provide wrappers. I also think that RNSScrollViewFinder might soon need to use more complicated logic. Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also use this logic for all cases, not only for Paper in debug mode, but it seemed like an overkill for getting first child.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also just do:

RNSScreenContentWrapper *contentWrapper = nil;
UIView *currentView = vc.view;
while ([currentView.subviews count] > 0) {
    currentView = currentView.subviews[0];
    if ([currentView isKindOfClass:RNSScreenContentWrapper.class]) {
        contentWrapper = static_cast<RNSScreenContentWrapper *>(currentView);
        break;
    }
}

performance difference will be negligible (especially if we expect the class to be correct) and it improves readability.

Copy link
Collaborator

@kmichalikk kmichalikk left a comment

Choose a reason for hiding this comment

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

One issue I found

image

on Paper, ScrollView overflows below the screen

Comment on lines +576 to +586
UIView *currentView = vc.view;
while (currentView != nil) {
if ([currentView isKindOfClass:RNSScreenContentWrapper.class]) {
contentWrapper = static_cast<RNSScreenContentWrapper *>(currentView);
break;
} else if ([currentView.subviews count] > 0) {
currentView = currentView.subviews[0];
} else {
break;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also just do:

RNSScreenContentWrapper *contentWrapper = nil;
UIView *currentView = vc.view;
while ([currentView.subviews count] > 0) {
    currentView = currentView.subviews[0];
    if ([currentView isKindOfClass:RNSScreenContentWrapper.class]) {
        contentWrapper = static_cast<RNSScreenContentWrapper *>(currentView);
        break;
    }
}

performance difference will be negligible (especially if we expect the class to be correct) and it improves readability.

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.

2 participants