FaridSafi / react-native-gifted-form

📝 « One React-Native form component to rule them all »
MIT License
1.44k stars 214 forks source link

Focus problem with Select Widget #63

Open pablojorreto opened 8 years ago

pablojorreto commented 8 years ago

There is a bug in the SelectWidget. While rendering the options using OptionWidget inside the Select Widget, if the property multiple is set to true you have to double tap in every Option to for selecting them.

Does someone know how to solve this?

bsy commented 8 years ago

+1

stwiname commented 7 years ago

The problem is in this line https://github.com/FaridSafi/react-native-gifted-form/blob/master/widgets/SelectWidget.js#L29

If the default value is false then it will use the title as the value. Changing https://github.com/FaridSafi/react-native-gifted-form/blob/master/widgets/SelectWidget.js#L43 to value: child.props.value, solves the problem for me

ebundala commented 7 years ago

The problem is in optionWidget on _onClose() method it uses this._onChange(!this.state.value) to set selection but this.state.value is true initially hence it will set false first then next tap will work I added a new state prevValue which initially is false and put it in this._onChange(!this.state.prevValue) it now works but I didn't understand why @stiwiname solution didn't work. logically it should work since it set the value to props.value n not title which forces the value to be true initially

ebundala commented 7 years ago

After testing it fails also I think the issue is in the _onChange handler it doesn't set the values accordingly what I was able to do is handling taps and render the checkmark accordingly but the value is a malformed JSON after console log

frmdstryr commented 7 years ago

The problem is it's trying to use the user passed option value as the checked state. The cloned widget should be using it's own internal checked state.

Set val: false in https://github.com/FaridSafi/react-native-gifted-form/blob/master/widgets/SelectWidget.js#L43 and it works.

bilalsyed001 commented 7 years ago

@frmdstryr setting value to just false breaks single SelectWidget for me. Using value: this.props.multiple ? false : val, fixes issue

mitchellbutler commented 6 years ago

I've confirmed @bilalsyed001's suggested fix and created a PR.