-
-
Notifications
You must be signed in to change notification settings - Fork 102
Long text inputs within ScrollView #937
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
Comments
Hey @TimurKr Thank you for such a descriptive issue ❤ Let's go over each item: KeyboardGestureAreaOverall approach is correct.
So you added the same KeyboardAvoidingViewCorrect, KeyboardAwareScrollView
Yeah, this is a know issue. I already have several issues about it. I guess I just need to find a time and finally fix it. The problem is that in initial design I completely missed the case, when TextInput can be larger than screen (i. e. Apple Notes, Gmail message composer etc.). This is a bug and definitely needs to be fixed! Currently I'm preparing for AppJS Conf talk and literally don't have a lot of time for fixing this, but I promise I'll try to fix it in the June 🙈 (getting a lot of complaints, so it needs to be fixed, yes).
Well, this one is strange 🤔 Can it be a default react-native behavior? My recommendation here would be to explore solutions from
Yes, current implementation relies on input layout, not the caret position. And this is the problem, when input is very big I literlly don't know the direction for scrolling, because top part of input is obscured by header, and bottom part is obscured by keyboard, so it's literally unpredictable. The correct approach is to use cursor coordinates and I'll re-work it. Custom solution
Maybe because of this?.. facebook/react-native#48412
I think you can solve it by using
Yeah, don't think it's related to keyboard-controller, but maybe RNGH can help here. So to sum up:
Let me now if you have any other questions - will be happy to answer on them 😊 |
Hey @kirillzyusko, incredible response, thanks for the details. Better customer support than most payed products ❤️ Regarding the
|
Hi, first of all, this seems like a great library, good job!
I'm quite new to react native but can already tell that getting th keyboard behaviour right is a major painpoint. I am building a simple notes app, almost an apple notes clone. No fancy rich text editing, just a couple simple multiline textinputs in a scroll view and a toolbar that should be sticky above the keyboard I tried using all of the hooks and components this library provides, but to no avail. I'll list my requirements, approaches I've tried, and share why they failed. This way you might point me in the directoin of a solution, you might notice some bugs in the library itself, and it might be a helpfull reference for other newcomers to this repo.
Requirements:
keyboardDismissMode="interactive"
), but the dismissal start at the top of the toolbar, not the keyboard itselfAll of the features above are directly taken from the behavior of the Apple notes app.
Tried solution
1.
KeyboardGestureArea
I tried using the
KeyboardGestureArea
to dismiss the keyboard with an offset, but that only works if the currentyl focused input has anativeID
set to the same value as thetextInputNativeID
on theKeyboardGestureArea
. As I have multiple text inputs, if I set the samenativeID
for all of them, removing the focus from the currently focused input closes the keyboard. As if there was a listener on the blur event of the input with the samenativeID
that closes the keyboard. I basically gave up on this and just accepted the closing starts on the top of the keyboard and not the toolbar.2.
KeyboardAvoidingView
I tried using
KeyboardAvoidingView
with aScrollView
, but just couldn't get it to work. Just too many issues and seems like to be the wrong approach anyway.3.
KeyboardAwareScrollView
I tried using
KeyboardAwareScrollView
, this got me very close, setting bothbottomOffset
andextraKeyboardSpace
to the toolbar size, works nicely. Some issues are still present though:4. Custom solution using
useReanimatedKeyboardAnimation
,useFocusedInputHandler
, anduseReanimatedFocusedInput
Finally I tried building my own solution, (see
components/CustomKeyboardAwareScrollView.tsx
). This got me the closest to the desired behaviour, but there are still some issues:measure
function returning the height of the scrollview before the keyboard is shown, so the calculations assumes the keyboard is hidden, so no scrolling happens)Related issues
I see this PR #901 solving this issue #897 is attempting to fix the long textinput and scrolling issues. I haven't tried the changes in it and see there are multiple comments suggesting changes before merge.
Sorry for the long comment, but it seems like this repo did most of the hard work around handling keyboards in RN, but the last 10% is missing. I spent over 10 hours on this issue and I still couldn't figure it out. If the functionality is there, perhaps the docs need improvement. Thanks for you hard work, if there is anything I could help with, let me know. Thanks for any tips on how to get this working!
Setup I was testing on:
The text was updated successfully, but these errors were encountered: