Skip to content
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

Close iOS Select when selection is made #403

Closed
wants to merge 6 commits into from

Conversation

zolrath
Copy link

@zolrath zolrath commented Sep 26, 2017

@alvaromb mentioned he'd take a pull request for this in #265
Currently, when presenting an enum in the form the default template provides a Picker on iOS.
This picker stays open after the user selects an option instead of automatically closing.

This pull request closes the picker 500ms after the user stops interacting with the Picker.
It detects pans on the View surrounding the Picker to ensure it doesn't close if the user is still panning the Picker after a selection is made, be it they are scrolling lower in the list or simply hovering over options.

Without using the PanResponder if the user lingered on an option too long or let go while attempting to scroll the list the Picker would close. Now, we cancel the automatic close timeout if the user is still dragging in the Picker.
@zolrath
Copy link
Author

zolrath commented Oct 2, 2017

Actually, if you tap the field to close it before it autocloses, it will automatically open back up.
I'll separate the onPress toggle and the autoclose functionality into more appropriate togglePicker and closePicker functions to correct the issue soon.

@zolrath
Copy link
Author

zolrath commented Oct 6, 2017

With togglePicker and closePicker extracted into separate functions this now operates as I would expect and should be ready you @alvaromb!

@NotTooReact89
Copy link

can you please give me an example of how this works?

@zolrath
Copy link
Author

zolrath commented Oct 18, 2017

It implements the behavior requested by #265.
Currently on iOS if you have a field with multiple options the Select list behavior is a bit unexpected.
You tap on the select list, it expands, and once you tap on an option the select list remains open.
In order to close the select list after picking your option, you need to click on the top of the select list again to close it.

This PR makes it so after tapping on an option the Select list closes itself automatically after 500ms.
If the user taps on another option or starts dragging the list before the 500ms have passed it will reset the timer so it doesn't disrupt scrolling through longer lists but allows for the behavior to be more like the Android select list.

@NotTooReact89
Copy link

sorry if i was not too clear on what i was asking. I have a form with the below select so what attribute should I use/how do i make use of this?

const SelectItems = t.enums({
Option1: 'Option 1',
Option2: 'Option 2'
}, "Select option");

SelectItems.getValidationErrorMessage = function () {
return 'Please select an option';
};

@ghost
Copy link

ghost commented Nov 5, 2017

I'm hoping this to get merged and released soon! Thanks

@pedroeusebio
Copy link

Nice solution !! worked like a charm, thanks @zolrath !

@otaviogaiao
Copy link

Thank you so much man. It works perfectly. I have spent hours trying to fix the behaviour of the select component. But your code fixed everything. This should be already merged.

@alvaromb
Copy link
Collaborator

Will merge this today, sorry for the delay.

@alvaromb
Copy link
Collaborator

Sorry @zolrath, could you please solve conflicts? There have been some deep changes in that picker

@tonycoco
Copy link
Contributor

tonycoco commented Jul 3, 2018

#507 also fixes this

@alvaromb
Copy link
Collaborator

@Moreno97 can you solve the conflicts for this PR?

@macrozone
Copy link

@zolrath any chance to get this merged soon?

@otaviogaiao
Copy link

@macrozone this PR has been open for so long and its something so important.. I think you should just fork the project and accept it yourself. Thats what I did, and its working great

@alvaromb
Copy link
Collaborator

Landed in: #527

Sorry for the delay, I didn't have time to look into this since today.

@alvaromb alvaromb closed this Sep 21, 2018
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.

7 participants