-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Dynamic bottomOffset
not respected when switching between inputs
#743
Comments
@Tobbe thank you for raising this issue 🙌 let me think a little bit about this problem and about potential ways to solve that and I'll get back to you. One solution I've been thinking of is putting useEffect(() => {
maybeScroll(keyboardHeight.value);
}, [bottomOffset]); But I just thinking whether such method can bring additional complexity or not and undesired bugs (pretty sure it will). Another solution I'm thinking of is exposing a method from a And I think the second approach requires more hand-engineering (which is bad), but at the same time it's more generic approach (for example if you have validation errors that shift layout down - in this case I can not detect such layout changes, so it can be kind of developer responsibility to call that method on Curious to hear your thoughts 👀 |
This is a good point! I haven't thought much about that yet. Let me play around a bit with error and how I display them in my app and see what I come up with |
Do you think this could be caused by From what I see, this hook picks up the
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;
}
},
[],
); |
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;
}
},
[],
); I think this code should detect only "input grow" event (at least it was originally designed to do that) 🤔 Input switching gets handled in |
Describe the bug
When I switch focus from one input to another and change the bottom offset used for my
<KeyboardAwareScrollView>
it doesn't seem to actually use the new offset. You can see in the code snippet below how I change the offset when I focus the second input. If I focus the second input directly everything works. But if I first focus the top input, and then go directly to focus the second one the offset seems to stay at 30Code snippet
This is obviously just parts of the code. See the linked repo for the full implementation
Repo for reproducing
https://github.com/Tobbe/rnkc-bottom-offset
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect the full button to always be visible after switching focus to the password input field
Screenshots
Here's a video of the behavior I'm seeing
Screen.Recording.2024-12-19.at.16.01.22.mov
Smartphone (please complete the following information):
Additional context
In this particular example I can just keep the offset to always be 90. But with more input fields, or just more text above the first one, always doing 90 (or more) feels like too much
Another workaround that kind of works is to also change the bottom offset when the text changes. So as soon as the user starts typing in the password input field the log in button scrolls into view.
The text was updated successfully, but these errors were encountered: