Skip to content

Individual (optional) bottomOffsets for TextInputs #1457

@skizzo

Description

@skizzo

Is your feature request related to a problem? Please describe.

The problem: KeyboardAwareScrollView doesn't handle this scenario well:

  1. bottomOffset value of KeyboardAwareScrollView is set to a state value (e.g.20)
  2. TextInput A - currently at the screen bottom - is tapped
  3. Soft Keyboard shows and scrolls TextInput A above it correctly (with a bottom offset of 20)
  4. TextInput A has these properties:
    returnKeyType={"next"}
    submitBehavior={"submit"}
    onSubmitEditing={() => {
        setBottomOffset(40) // change bottomOffset used in KeyboardAwareScrollView parent
        textInputB.current?.focus()
    }}
    
  5. User taps on soft keyboard's "Next" button
  6. KeyboardAwareScrollView does not smoothly jump to TextInput B's bottom (with a bottom offset of 40).

Describe the solution you'd like

In case of a complex form that optionally shows and hides errors or info texts between TextInputs based on state that can change while the soft keyboard is shown, it would be handy to define the bottomOffset property either

  • a: as a number (as it is at the time of writing this), or
  • b: additionally, add bottomOffsets as an object of the type {[nativeID: string]: number | undefined}. The nativeID could be used internally to determine the scroll target not only based on the bottomOffset property, but also consider bottomOffsets?.[nativeID] and use it as an override, if given.

Describe alternatives you've considered

Manually measuring and scrolling to a focused TextInput, which defeats the purpose of this great library.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions