Skip to content

Conversation

@bugs181
Copy link
Contributor

@bugs181 bugs181 commented May 8, 2018

Adds an update method to allow components the ability to re-scroll to the selected field based on some user-defined event.

Fixes issues that most users are having with auto-growing, resizing, updated or multiline TextInput fields.

Videos

Without fix:

update-broken

With fix:

update-fix

Example use:

In component file:

render() {
    return (
        <KeyboardAwareScrollView extraScrollHeight={ 100 } ref='KeyboardAwareScrollView'>
            <TextInput ... />
        </KeyboardAwareScrollView>
     )
}

componentDidUpdate() {
  let keyboardScrollView = this.refs.KeyboardAwareScrollView

  if (keyboardScrollView)
    keyboardScrollView.update()
}

closes #250

Adds an `update` method to allow components the ability to re-scroll to the selected field based on some user-defined event.

Fixes issues that most users are having with auto-growing, resizing, updated or multiline `TextInput` fields.

Examples and Videos description

closes APSL#250
Copy link

@AndreiCalazans AndreiCalazans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be awesome if we could get this merged. 💯
@alvaromb

@alvaromb
Copy link
Collaborator

alvaromb commented Jun 6, 2018

Super cool!

Will merge & release today. Thanks!

@Landcross
Copy link

Any update on when this PR will be merged and released?

@alvaromb
Copy link
Collaborator

@Landcross today is the day!

@alvaromb alvaromb merged commit ce6e338 into APSL:master Jun 22, 2018
@msageryd
Copy link

msageryd commented Jul 16, 2018

This is really great!
Sadly It doesn't work for me. Anyone else having problem with auto-scroll to multiline TextInput components?

Non multiline textinputs works fine. Any ideas of where to start debugging?

Edit: I'm on RN 0.56

@iRoachie
Copy link
Contributor

Confirming doesn't work in 0.56

@zachrnolan
Copy link

zachrnolan commented Aug 17, 2018

I'm on RN 0.53 and KeyboardAwareFlatList is working, but KeyboardAwareScrollView isn't.

@bugs181 - Any ideas why this wouldn't apply to all of the components?

@alvaromb
Copy link
Collaborator

I can confirm it doesn't work for 0.56. @bugs181 have you experienced the same issue?

@bryantee
Copy link

bryantee commented Aug 31, 2018

Not working for us either. We're forced to go back to using a static input height and just scrolling within...

EDIT:
I can confirm this is working for us on RN 55.4 and KASV 0.7.2

@justinwaite
Copy link

Working for me on 0.57.1, however the inputs must be controlled inputs in order to update the state of the component, thus triggering the scroll view update. Here's my environment info:

 React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 26.66 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.11.4 - ~/.nvm/versions/node/v8.11.4/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.4/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5014246
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0 
      react-native: 0.57.1 => 0.57.1 
    npmGlobalPackages:
      create-react-native-app: 2.0.2
      react-native-cli: 2.0.1

@bugs181
Copy link
Contributor Author

bugs181 commented Dec 6, 2018

Apologies to everyone! It appears Github notifications are on the fritz again. I never received any notifications regarding this thread. I haven't had the opportunity to check what broke in recent releases however have an idea. Recently React has been deprecating lifecycles and changing how some of them behave.

That said, some of you are asking why this does not apply to inputs that aren't "controlled". The PR was originally only intended to update the input that the user is focused on. When/If I have time in the near future, I'll look for an alternative method in KASV to retrieve the input you're intending to update.

@bugs181 bugs181 deleted the update-method branch February 19, 2020 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Force scroll update

10 participants