Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyboardAwareScrollView scrolling too much when pasting a lot of content in multiline inputibox #348

Closed
domenicoprestia opened this issue Jan 30, 2024 · 15 comments
Assignees
Labels
🐛 bug Something isn't working 📚 components Anything related to the exported components of this library KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component

Comments

@domenicoprestia
Copy link

Describe the bug
It happens that when i try to paste a big chunk of text in a multiline TextInput that requires the KeyboardAwareScrollView to scroll, the scroll happens, but it's not as precise as in other times, it looks like it scrolls to much.

Code snippet
Cant share code since is a private repo, but its a TextInput inside a KeyboardAwareScrollView

To Reproduce
Steps to reproduce the behavior:

  1. Create a KeyboardAwareScrollView with an input component at 3/4 of the screen
  2. Try to paste a really big chunk of text
  3. See error

Expected behavior

Having the right scroll space without scrolling too much

Screenshots

Screen.Recording.2024-01-30.at.09.36.17.mov

Smartphone (please complete the following information):

  • Desktop OS: [MacOS 10.15.5]
  • Device: [e.g. Android Resizable (happens on any android)]
  • RN version: [e.g. 0.72.6]
  • RN architecture: [old fabric]
  • JS engine: [Hermes]
  • Library version: [latest]

Additional context
Add any other context about the problem here.

@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 📚 components Anything related to the exported components of this library labels Jan 30, 2024
@kirillzyusko
Copy link
Owner

@domenicoprestia maybe double scroll happens because of "simultaneous" layout & text-change handlers?

Would you mind to try to remove this code:

useAnimatedReaction(
      () => input.value,
      (current, previous) => {
        if (
          current?.target === previous?.target &&
          current?.layout.height !== previous?.layout.height
        ) {
          const prevLayout = layout.value;

          layout.value = input.value;
          scrollPosition.value += maybeScroll(keyboardHeight.value, true);
          layout.value = prevLayout;
        }
      },
      [],
    );

And see whether it fixes the problem?

@domenicoprestia
Copy link
Author

yes i'll try instantly, in which file can i find it?

@domenicoprestia
Copy link
Author

i've just tried and without that chunk of code it does not scroll when pasting

@kirillzyusko
Copy link
Owner

@domenicoprestia doesn't scroll at all or doesn't scroll too much (i. e. expected/desired behavior)? 😅

@domenicoprestia
Copy link
Author

when i remove it it does not scroll at all, sorry for not being too specific 😅

@kirillzyusko
Copy link
Owner

Hi @domenicoprestia

I've tried to reproduce the problem in example app, but no luck - maybe you can provide a code snippet with minimal reproduction example?

iOS Android
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-01-31.at.20.09.32.mp4
telegram-cloud-document-2-5321496636164161963.mp4

@domenicoprestia
Copy link
Author

Sorry, just saw this comment, i'll try to reproduce it again and to give you more background informations on this

@kirillzyusko kirillzyusko added the KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component label May 29, 2024
@kirillzyusko
Copy link
Owner

@domenicoprestia may I ask you which Android version were you using in your tests?

@kirillzyusko
Copy link
Owner

@domenicoprestia it could be fixed in latest 1.12.4 version - can you verify, please?

@iphonic
Copy link

iphonic commented Jun 25, 2024

@kirillzyusko I am facing a different scroll issue, when text is long and paste on TextInput the scroll won't scroll down, it starts scrolling when you try to scroll couple of time after a fraction of time. Also when we scroll the text manually and try to retype the offset is broken which means the TextInput scrolls up way too much when type. I am using the latest 1.12.4.

@kirillzyusko
Copy link
Owner

@iphonic can you provide a minimal reproduction example, please? 🙏

@iphonic
Copy link

iphonic commented Jun 25, 2024

@kirillzyusko Yes I am doing this

<KeyboardAwareScrollView bottomOffset={40}>
     <View style={{flex:1}}>
          <TextInput
                placeholder={'Compose Your Message'}
                multiline
                style={styles.contentText}
                value={message}
                onChangeText={(value) => setMessage(value)}
           />
     </View>
</KeyboardAwareScrollView>

Attached a recording of what's happening, it doesn't allow to scroll up or down, need to do it multiple times.

RPReplay_Final1719336468.mp4

@kirillzyusko
Copy link
Owner

@iphonic can you try to replace KeyboardAwareScrollView with ScrollView? Does the problem with scrolling remains?

On my simulator the problem with scrolling remains - if you scroll outside of the input you can scroll, if you scroll within an input -> it doesn't scroll and it's expected 🤷‍♂️

@kirillzyusko
Copy link
Owner

I strongly believe that the issue was fixed in 21eff3b and I'm closing the issue. If you discover that the problem still remains, feel free to open a new issue or leave a comment here and I'll re-open the issue.

A small reproduction example will significantly speed up the process of the fix 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 📚 components Anything related to the exported components of this library KeyboardAwareScrollView 📜 Anything related to KeyboardAwareScrollView component
Projects
None yet
Development

No branches or pull requests

3 participants