Skip to content

Tapping between TextFields breaks keyboard avoidance #1

@bennokress

Description

@bennokress

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 the ViewModifier 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):

var focusedTextInputBottom = UIResponder.currentFirstResponder?.globalFrame?.maxY ?? 0
focusedTextInputBottom` += self.bottomPadding

It seems to fix the problem, but I'm not sure about possible side effects and if this calculation is always right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions