Skip to content

feat: use contentInset for KeyboardAwareScrollView#797

Merged
kirillzyusko merged 8 commits intomainfrom
fix/use-content-inset-for-keyboard-aware-scroll-view
Feb 1, 2026
Merged

feat: use contentInset for KeyboardAwareScrollView#797
kirillzyusko merged 8 commits intomainfrom
fix/use-content-inset-for-keyboard-aware-scroll-view

Conversation

@kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented Feb 3, 2025

📜 Description

Use ScrollViewWithBottomPadding component for KeyboardAwareScrollView to optimize performance and fix other issues that were caused by the fact of usage additional view inside ScrollView.

💡 Motivation and Context

In this PR I'm moving away from the idea of having a fake view in the end of the ScrollView and instead start to use ScrollViewWithBottomPadding component to achieve a desired visual effect.

The additional view causes many issues such as:

  • unintended layout shift if flex: 1 style is used;
  • broken auto-grow for multiline input;
  • unexpected styling issues if you use gap/justifyContent: "space-between" and other properties.

In this PR I'm switching to the component that has been added in #1294 With its new power I can achieve cross-platform behavior and:

  • without layout modification add a scrollable padding;
  • get the same behavior on both iOS/Android;
  • don't use any hidden children that can break something.

This PR has been opened for a long time, but finally can be merged because I got working version on Android.

Closes #794 #645 #929 #168

Potentially: #748 software-mansion/react-native-reanimated#5567 #719

Unlocks one item from #883

📢 Changelog

JS

  • added useScrollState hook;
  • use ScrollViewWithBottomPadding component in KeyboardAwareScrollView;
  • added removeGhostPadding in KeyboardAwareScrollView and use it there.

E2E

  • update assets for KeyboardToolbarClosed test-case.

🤔 How Has This Been Tested?

Tested manually on:

  • iPhone 17 Pro (iOS 26.2, simulator);
  • Pixel 7 Pro (API 36, real device);
  • e2e_emulator_28 (API 28, emulator);;
  • all e2e devices;

📸 Screenshots (if appropriate):

iOS Android
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-02-01.at.16.46.14.mov
Screen.Recording.2026-02-01.at.16.49.23.mov

📝 Checklist

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

@kirillzyusko kirillzyusko added refactor You changed the code but it didn't affect functionality KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component labels Feb 3, 2025
@kirillzyusko kirillzyusko self-assigned this Feb 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2025

📊 Package size report

Current size Target Size Difference
241763 bytes 237686 bytes 4077 bytes 📈

kirillzyusko added a commit that referenced this pull request Jan 28, 2026
## 📜 Description

Added `ClippingScrollView` component (on Android only) that is supposed
to act as a polyfill for `contentInset: {bottom}` property of
`ScrollView`.

## 💡 Motivation and Context

Those changes are based on my PR from
facebook/react-native#49145

The big problem with original PR is that it wasn't working correctly, if
we specify all insets/paddings simultaneously. But! It worked well for
`bottom` inset property (keyboard-controller case, because keyboard
appears from the bottom of the screen). I think it's risky to ship a
code in this state into facebook codebase, so I decided to add those
changes into `react-native-keyboard-controller` first. It's good
because:

- I have a full ownership of the code and I can fix bugs quickly
(without waiting for a new RN release);
- we don't ship buggy code in react-native repository;
- we don't depend on react-native version and we don't need to write a
conditional code, like "if prop is supported, then use new approach and
if not, then fallback to old implementation".

The approach that I've choose is based on "decorator" approach - this
approach has been used in many other libs, such as
`advanced-input-mask`, `live-markdown` etc. The idea is that we create
our custom view that wraps our target view and then we access a target
view as a children (and we can modify behavior/props of this view).

I'm going to use this component in `KeyboardAwareScrollView` and in new
`ChatKit` component. From lessons learned from the previous experience I
can confidently say, that additional view near children will cause
issues and this polyfill for `contentInset: {bottom}` should hopefully
solve all the issues that we had. I'll continue experiments with this
view in
#797

## 📢 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 -->

### JS

- added codegen component;
- added new types props for new component;
- added jsdoc for new component;

### Android

- added `ClippingScrollView`;

## 🤔 How Has This Been Tested?

Tested in example app in `KeyboardAwareScrollView` screen and in new
component that is currently under active development 😊 Everywhere works
stable on both architectures 🤞

## 📸 Screenshots (if appropriate):

|KeyboardAwareScollView|Non inverted chat list|
|--------------------------|---------------------|
|<video
src="https://github.com/user-attachments/assets/0f7efef7-ec15-4fe6-96cb-40334f0c91ad">|<video
src="https://github.com/user-attachments/assets/92093e87-434a-4c82-91d5-1c7e9706e5f0">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
@kirillzyusko kirillzyusko force-pushed the fix/use-content-inset-for-keyboard-aware-scroll-view branch from 29efbf3 to f11412f Compare January 28, 2026 12:03
@kirillzyusko kirillzyusko force-pushed the fix/use-content-inset-for-keyboard-aware-scroll-view branch from 9e74ef9 to 17bc9d4 Compare January 29, 2026 10:10
@kirillzyusko kirillzyusko added enhancement New feature or request 🚀 optimization You optimize something and it becomes working faster and removed refactor You changed the code but it didn't affect functionality labels Jan 31, 2026
@kirillzyusko kirillzyusko marked this pull request as ready for review February 1, 2026 15:51
@kirillzyusko kirillzyusko merged commit 423dbef into main Feb 1, 2026
30 of 32 checks passed
@kirillzyusko kirillzyusko deleted the fix/use-content-inset-for-keyboard-aware-scroll-view branch February 1, 2026 15:54
Copy link
Owner Author

@kirillzyusko kirillzyusko Feb 1, 2026

Choose a reason for hiding this comment

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

Caught a regression on iOS 26 + Xcode 16 👍

@kirillzyusko kirillzyusko mentioned this pull request Feb 1, 2026
2 tasks
kirillzyusko added a commit that referenced this pull request Feb 1, 2026
## 📜 Description

Fixed iOS e2e tests.

## 💡 Motivation and Context

The pipeline got broken here:
#797

iOS 18 tests were failing because of 1 asset <- just updated one
screenshot
iOS 26 + XCode 16 were failing because of 2 assets <- things went harder
here

On `iOS 26 + XCode 16` I used old iOS 26.0 version, which resulted in a
wrong behavior. It was hard to fix it in the lib codebase, so I just
decided to switch to a new iOS version. For that I had to update all
snapshots.

## 📢 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 -->

### E2E

- updated iOS e2e assets;
- use iOS 26.2 instead of iOS 26.0.

## 🤔 How Has This Been Tested?

Tested manually via e2e run on a failed exam.

## 📸 Screenshots (if appropriate):

<img width="858" height="395" alt="image"
src="https://github.com/user-attachments/assets/58850c15-2bc4-4d6a-9159-97eafce64a25"
/>

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component 🚀 optimization You optimize something and it becomes working faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiline TextInput Auto-growing and Scrolling Behavior Issues with KeyboardAwareScrollView

1 participant