react-native-picker-select icon indicating copy to clipboard operation
react-native-picker-select copied to clipboard

Fix: Scroll to TextInput on picker opening

Open chrispader opened this issue 2 years ago • 11 comments

Problem

When the picker gets opened, the <ScrollView /> which contains the <RNPickerSelect /> isn't responding to the modal opening.

Since using the picker should feel like using keyboard, we need to have some logic to directly scroll to the location of the <TextInput /> in the containing <ScrollView />.

Solution

I added the code needed, to allow this kind of functionality. There are two props needed:

  • scrollViewRef: A ref to the containing <ScrollView /> component, so we can manuall call .scrollTo()
  • scrollViewContentOffsetY: the current scrolling offset, which can be retrieved by using the onScroll callback on the <ScrollView />

(Lmk if you have a solution, that requires less props or is easier)

This is completely optional, so if these 2 props are not provided, the behaviour of this picker library won't change

Notices

Hope this PR brings some useful functionality.

chrispader avatar Jan 07 '23 02:01 chrispader

this is cool - can you fix the conflicts?

lfkwtz avatar Aug 28 '23 18:08 lfkwtz

@lfkwtz conflicts resolved 👍

chrispader avatar Aug 28 '23 18:08 chrispader

@lfkwtz just found a reliable way to measure the actual modal height, without the need to hardcode it. Let me know what you think and if everything works for you 👍

chrispader avatar Sep 14 '23 12:09 chrispader

looking good - able to close that coverage gap?

lfkwtz avatar Oct 26 '23 19:10 lfkwtz

looking good - able to close that coverage gap?

Not sure how, if were not able to test this lib natively on iOS... Do you have an idea?

chrispader avatar Oct 27 '23 09:10 chrispader

@lfkwtz do you think we can merge this? Absolutely no priority though..

chrispader avatar Dec 30 '23 13:12 chrispader

@lfkwtz do you think we can merge this? Absolutely no priority though..

i currently do not have access to merge until all checks are passed. so we'll have to work through that first.

lfkwtz avatar Jan 10 '24 21:01 lfkwtz

I'm gonna try to continue working on the tests if i get the chance any time soon...

chrispader avatar Mar 27 '24 15:03 chrispader

looks like the team at lawnstarter is starting to work on this a bit more so maybe they will be able to help you get this in cc @alberto-mourao-lawnstarter

lfkwtz avatar Mar 29 '24 11:03 lfkwtz

looks like the team at lawnstarter is starting to work on this a bit more so maybe they will be able to help you get this in cc @alberto-mourao-lawnstarter

ah awesome! Yea, if they could help me with fixing/setting up these tests, that would be great! thanks

chrispader avatar Mar 29 '24 11:03 chrispader

gonna resolve merge conflicts soon

chrispader avatar Mar 29 '24 11:03 chrispader