Skip to content

Commit 76056c3

Browse files
authored
fix: KeyboardAwareScrollView loosing ref identity (#1319)
## 📜 Description Fixing loosing `ref` identity for `KeyboardAwareScrollView` on RN 0.83+ ## 💡 Motivation and Context We were re-creating ref. However starting from RN 0.83 it's not allowed, see: #1317 In this PR we just extend existing ref with new method. This was a suggested fix and according to e2e pipeline it works and works well 🤞 Closes #1317 ## 📢 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 - inject new method into ref instead of re-creating it; ## 🤔 How Has This Been Tested? Tested by e2e test. ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 6c25251 commit 76056c3

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • src/components/KeyboardAwareScrollView

src/components/KeyboardAwareScrollView/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,18 @@ const KeyboardAwareScrollView = forwardRef<
497497
() => {
498498
const scrollView = scrollViewRef.current;
499499

500-
const existingMethods = scrollView ? { ...scrollView } : {};
500+
if (scrollView) {
501+
const scrollViewWithMethods =
502+
scrollView as KeyboardAwareScrollViewRef;
501503

502-
return {
503-
...existingMethods,
504+
scrollViewWithMethods.assureFocusedInputVisible = () => {
505+
synchronize();
506+
};
504507

508+
return scrollViewWithMethods;
509+
}
510+
511+
return {
505512
assureFocusedInputVisible: () => {
506513
synchronize();
507514
},

0 commit comments

Comments
 (0)