Skip to content

fix(SNOTES-468): use injectJavascript to set safe area inset vars #2907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025

Conversation

antsgar
Copy link
Contributor

@antsgar antsgar commented Jun 23, 2025

I've only been able to repro this on my production app by leaving the app open (minimized) overnight and then focusing on it again the next day. I'm not entirely sure what's going on, but I suspect that in those conditions either the effect that triggers the message to update the insets isn't fired, or the condition that checks for didAppLaunch before sending the message returns false.

This PR sets the CSS safe area inset vars using injectJavascript instead of postMessage. Injecting JS is actually the recommended way to pass information from RN to Web per the react-native-webview docs, and there's an example in the docs where this is used to update the background color of the webview https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#the-injectjavascript-method. This will run on every render, and that way we ensure that the correct inset paddings are always being set.

@antsgar antsgar requested a review from amanharwara June 23, 2025 15:05
@amanharwara amanharwara merged commit c050a2c into main Jun 24, 2025
7 of 8 checks passed
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