Skip to content

KeyboardAvoidingView/Flatlist Scrolling When Modal Opened After TextInput Blurred Android Fix#1502

Closed
MatWaller wants to merge 2 commits into
kirillzyusko:mainfrom
MatWaller:main
Closed

KeyboardAvoidingView/Flatlist Scrolling When Modal Opened After TextInput Blurred Android Fix#1502
MatWaller wants to merge 2 commits into
kirillzyusko:mainfrom
MatWaller:main

Conversation

@MatWaller

@MatWaller MatWaller commented Jun 16, 2026

Copy link
Copy Markdown

📜 Description

Gaurding removeGhostPadding scrollTo when the keyboard is closed and a modal is opened.

Adding example flatlist form to example application

💡 Motivation and Context

Need this fix for a production application.

I have opened a bug report

📢 Changelog

Added guard to removeGhostPadding

JS

Added guard to removeGhostPadding

iOS

No native changes.

Android

No native changes.

🤔 How Has This Been Tested?

Ran through the exact steps to reproduce the issue outlines in the bug report and all is working as expected.

📸 Screenshots (if appropriate):

Have attached a video in the bug report - this no longer happens with this in place

📝 Checklist

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

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
319344 bytes 319458 bytes -114 bytes 📉

@MatWaller

Copy link
Copy Markdown
Author

@kirillzyusko Have updated pull request to remove example as don't feel it was needed fix is simple enough.

@kirillzyusko kirillzyusko self-assigned this Jun 17, 2026
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🌎 modal Anything that involves Modal usage KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component labels Jun 17, 2026
kirillzyusko added a commit that referenced this pull request Jun 19, 2026
…#1503)

## 📜 Description

Fixed an issue when closing a `Modal` triggers undesired scrolling in
`KeyboardAwareScrollView`.

## 💡 Motivation and Context

The issue is because when `Modal` gets closed we dispatch only
`onMove`/`onEnd` events. In `KeyboardAwareScrollView` in `onStart`
method we have a lot of logic that computes current input position
before keyboard animation, calculates offset etc. If we skip this stage,
then `onMove`/`onEnd` may use values from previous keyboard interaction
(so if keyboard was closed before and we scrolled for ~100px) we may
scroll again, because values from `onStart` were not updated.

Technically that problem could be fixed in `KeyboardAwareScrollView`
with additional conditions, but we use `useKeyboardHandler` hook in so
many places/components, so if we would use this approach we potentially
might need to replicate this fix in `KeyboardAvoidingView` and other
components (and lib users would also need to do that if they use this
hook in their projects).

So I think the correct fix is to fix inconsistency in native code.

Funny enough, but the new `syncKeyboardPosition` now becomes very
similar to `onKeyboardResized`, especially since both functions are used
in `onApplyWindowInsets` and I think that in the future these methods
can be unified. Moreover the condition with detection keyboard resize or
double keyboard position synchronization also can be unified and as a
result we can make the codebase simpler. But this is the next step.
First of all we need to merge/release this PR and keep an eye on
possible bug reports about new bugs that caused by these changes 👀

Closes
#1501
#1502

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### Android

- send `onStart` event too from `syncKeyboardPosition` function;

## 🤔 How Has This Been Tested?

Tested manually on Pixel 7 Pro (API 36, real device).

## 📸 Screenshots (if appropriate):

|Before|After|
|-------|-----|
|<video
src="https://github.com/user-attachments/assets/0a08edd8-ed27-4ee4-9b77-c469516d9e85">|<video
src="https://github.com/user-attachments/assets/ab430e99-202f-4595-b8c1-225fc7378b11">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
@kirillzyusko

Copy link
Copy Markdown
Owner

Closing as it was handled in #1503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component 🌎 modal Anything that involves Modal usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants