Skip to content

fix: automatically detect top border of KeyboardAwareScrollView#1352

Merged
kirillzyusko merged 2 commits intomainfrom
fix/automatically-detect-top-border-of-keyboard-aware-scroll-view
Mar 12, 2026
Merged

fix: automatically detect top border of KeyboardAwareScrollView#1352
kirillzyusko merged 2 commits intomainfrom
fix/automatically-detect-top-border-of-keyboard-aware-scroll-view

Conversation

@kirillzyusko
Copy link
Copy Markdown
Owner

@kirillzyusko kirillzyusko commented Mar 10, 2026

📜 Description

Automatically detect top border of KeyboardAwareScrollView.

💡 Motivation and Context

Continue the epic with better discovery of component location on the screen and logical continuation of #1346

In this PR I started to detect relative position of ScrollView, so that I better understand if caret is not visible because it obscured by other elements (header etc.) It's still not perfectly implemented and there is still a "blind"/"dead" zone where text is already hidden but scroll doesn't happen. I'll fix it in following PRs but for now I just want to bring these changes to upcoming 1.21.0 release 🤞

We also can't use measureInWindow because it produces incorrect measurements, so we need to use our custom implementation that has been added in #1355

Significantly improves UI for behavior described in #1341

📢 Changelog

JS

  • auto detect position of KeyboardAwareScrollView on the screen to better understand top border of the component relative to screen;

🤔 How Has This Been Tested?

Tested manually on iPhone 17 Pro (iOS 26.2, simulator).

📸 Screenshots (if appropriate):

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-03-10.at.19.43.33.mov

📝 Checklist

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

@kirillzyusko kirillzyusko self-assigned this Mar 10, 2026
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component labels Mar 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 10, 2026

📊 Package size report

Current size Target Size Difference
303644 bytes 303074 bytes 570 bytes 📈

@kirillzyusko kirillzyusko force-pushed the fix/automatically-detect-top-border-of-keyboard-aware-scroll-view branch from fb2e0d4 to 5d60c05 Compare March 12, 2026 16:06
@kirillzyusko kirillzyusko added the 🌎 modal Anything that involves Modal usage label Mar 12, 2026
@kirillzyusko kirillzyusko marked this pull request as ready for review March 12, 2026 16:17
@kirillzyusko kirillzyusko merged commit 6872736 into main Mar 12, 2026
14 of 16 checks passed
@kirillzyusko kirillzyusko deleted the fix/automatically-detect-top-border-of-keyboard-aware-scroll-view branch March 12, 2026 17:49
kirillzyusko added a commit that referenced this pull request Mar 18, 2026
## 📜 Description

Silent `could not fing view for tag` warning for
`KeyboardAwareScrollView` (similarly how it works for
`KeyboardAvoidingView` now).

## 💡 Motivation and Context

This issue got introduced after
#1352
(which was based on
#1346)

In certain cases `onLayout` may be triggered but view may be not laid
out yet (if you use it with `react-native-pager` lazy). Since changes in
#1352
were purely additional (we try to understand the position of element on
the screen, but before these changes we always assumed we were in the
top of the screen) I decided to wrap it for now in `try/catch` block.

Silenting error is not a correct fix, but this is the best what we can
do now - we will not spam logs when devs update the package (in
#1346
we also used `catch` block), but yes, in certain cases detection of top
border will not work (and it didn't work before, so it's fair enough to
silent the error).

Closes
#1375

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

- handle rejected promises within `try/catch` block;

## 🤔 How Has This Been Tested?

Tested via e2e tests, I didn't test changes manually because I don't
have a repro.

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
@kirillzyusko kirillzyusko mentioned this pull request Apr 27, 2026
2 tasks
kirillzyusko added a commit that referenced this pull request Apr 27, 2026
## 📜 Description

Fixed `IllegalViewOperationException` crash on Android.

## 💡 Motivation and Context

Original code has been introduced in
#1355
and further started to be used in
#1352

Now if view is not found it throws an unhandled exception and crashes
the app. In reality we already handle "view not found" exception, so we
should just add a proper try/catch block to handle this error correctly
in Kotlin code 🤞

Closes
#1443

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

- wrap `resolveView` with `catch (e: IllegalViewOperationException)`;

## 🤔 How Has This Been Tested?

Tested via e2e pipeline.

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

🐛 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.

1 participant