-
Notifications
You must be signed in to change notification settings - Fork 36
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
Tapping between TextFields breaks keyboard avoidance #1
Comments
Thanks for reporting the problem! I am afraid, I also don't have a solution yet. I was able to reproduce the issue for multiple text fields inside |
This fix makes general sense to me. Another way to reproduce the problem here is to switch between the English and Emoji keyboards: you will see the view oscillate up and down as (I think) it applies too little padding, then corrects, then applies too little padding again. You can see this especially clearly if you hardcode a tall keyboard height e.g. always return 500 here. However, I'm not sure that adding VStack {
VStack(alignment: .leading, spacing: 10) {
Text("Tap and hold the ") + Text("Globe").bold() + Text(" icon")
Text("Tap ") + Text("Searchboard").bold() + Text(" to switch keyboards")
}
TextField("", isEditing: $text)
}
.keyboardAdaptive() |
Corroborating the UIResponder.currentFirstResponder?.globalFrame?.maxY a couple of seconds after updating the bottom padding, it's only translated upward by half Not sure why |
To reproduce the issue, use 2 TextFields in need of keyboard awareness and tap the lower one. The scroll here will be correct, but tap the upper TextField while the keyboard is still showing and the bottom padding will be too little resulting in a (partially) hidden TextField. This issue seems to be caused by
focusedTextInputBottom
in theViewModifier
which is calculated based on the already scrolled View.If I find the time I will look into this further myself. My current solution is taking the bottomPadding at the time of the calculation into account (in the
ViewModifier
):It seems to fix the problem, but I'm not sure about possible side effects and if this calculation is always right.
The text was updated successfully, but these errors were encountered: