Skip to content

fix: don't modify edge-to-edge mode by default when module toggled on/off#1412

Merged
kirillzyusko merged 6 commits intomainfrom
fix/insets-manipulation
Apr 10, 2026
Merged

fix: don't modify edge-to-edge mode by default when module toggled on/off#1412
kirillzyusko merged 6 commits intomainfrom
fix/insets-manipulation

Conversation

@kirillzyusko
Copy link
Copy Markdown
Owner

@kirillzyusko kirillzyusko commented Mar 28, 2026

📜 Description

Don't hook up in insets calculation since it infers with many other libraries (such as react-native-screens, react-native-safe-area-context and other native libs such as RevenueCat paywalls).

💡 Motivation and Context

Original code has been introduced in #227

The idea was simple - to use this library we need:

  • enable edge-to-edge;
  • set keyboard callbacks;

So when we turn off functionality we need:

  • disable edge-to-edge;
  • remove keyboard callbacks.

However there was one problem - when we were disabling edge-to-edge we saw a visual jump:

telegram-cloud-document-2-5440655251046692537.mp4

That was caused by @react-navigation/stack + react-native-safe-area-context. The react-native-safe-area-context was emitting "wrong" events (we expected 0 insets):

Image

This is why I added a code with nulling insets. However it opens new issues like #1292 or #1013

In this PR I'm revisiting the implementation and I do one small trick: now we will not toggle edge-to-edge mode (in Android 16 it's enabled by default anyway without ability to turn it off) - instead we'll apply bottom padding/margin when keyboard appears (only when module turned off and input mode=resize, since resize + edge-to-edge acts as a adjustNothing). Yes, this is effectively a simulation of pre-edge-to-edge behavior and this simulation may not work everywhere perfectly (for example Android 16 would act differently before, since edge-to-edge is not disableable and even if you turn off the mode the keyboard wouldn't resize the window - with this solution it will, but at the same it bring consistency and reduces API fragmentation which is also good).

I don't think this is a breaking change, so it can be published as a patch release 🤞

Closes #1292 #1013

Possibly #1179 #1192

📢 Changelog

Android

  • removed replaceStatusBarInsets;
  • created extension for windowSoftInputMode;
  • use windowSoftInputMode extension in KeyboardControllerModuleImpl file;
  • don't replaceStatusBarInsets in global setOnApplyWindowInsetsListener(rootView);
  • don't disable edge-to-edge mode;
  • apply bottom padding if module disabled and ADJUST_RESIZE mode is active and preserveEdgeToEdge is false;

🤔 How Has This Been Tested?

Tested manually on Pixel 7 Pro (API 36).

📸 Screenshots (if appropriate):

Before After
image image

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Mar 28, 2026
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🤖 android Android specific labels Mar 28, 2026
@kirillzyusko kirillzyusko changed the title fix: don't modify edge-to-edge mode by default when module toggled on… fix: don't modify edge-to-edge mode by default when module toggled on/off Mar 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 28, 2026

📊 Package size report

Current size Target Size Difference
309512 bytes 309906 bytes -394 bytes 📉

@kirillzyusko kirillzyusko force-pushed the fix/insets-manipulation branch from 2236248 to b09609a Compare March 31, 2026 08:56
@Nezz
Copy link
Copy Markdown

Nezz commented Apr 8, 2026

I have verified that this fixes the edge-to-edge issues we were seeing (titles of screens being under the status bar) with Android 15 and 16.

@marco242424
Copy link
Copy Markdown

This fixed it for me aswell. Can we get it merged?

@kirillzyusko kirillzyusko marked this pull request as ready for review April 10, 2026 09:31
@kirillzyusko kirillzyusko merged commit e979dbf into main Apr 10, 2026
17 checks passed
@kirillzyusko kirillzyusko deleted the fix/insets-manipulation branch April 10, 2026 10:11
kirillzyusko added a commit that referenced this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 android Android specific 🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The library interacts oddly with Android header height in @react-navigation/native-stack

3 participants