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

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

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

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
Projects
None yet
Development

No branches or pull requests

2 participants