Tcomb-form-native: Add an `enabled` prop to make pickers editable.

Created on 1 Aug 2016  路  2Comments  路  Source: gcanti/tcomb-form-native

Picker has an enabled prop that enables/disables the picker behaviour. We should extend this prop to both Select and DatePicker components.

In the case of Select, the prop disables the picker but not the Touchable component that wraps it, leaving a very strange behaviour where you can open the picker but not scroll through it.

Enhancement

All 2 comments

Hello,

I just came across the issue that I wanted to show a Select and DatePicker component at first disabled w/ default / previously stored value. When clicking on a button both should get editable again.

Solved this by adding the disabled prop to TouchableOpacity in the CollapsiblePickerIOS and CollapsibleDatePickerIOS template, like so :

<TouchableOpacity
  style={touchableStyle}
  disabled={!locals.enabled}
  onPress={...}
>
  <Text style={dateValueStyle}>
    {formattedValue}
  </Text>
</TouchableOpacity>

As CollapsibleDatePickerIOS has no enabled prop by itself, I had to temporarily make an own factory and add it to the locals. Maybe you can add it by default to CollapsibleDatePickerIOS.

I hope that my thoughts are right and maybe this fits your issue.

@VLNTNA
It doesn't work when we open the Select and some callback change enabled to false in props. The state doesn't change and the opened select list is opened.
We need to check states in componentWillReceiveProps and close the Select.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pocesar picture pocesar  路  4Comments

timdoes picture timdoes  路  4Comments

abdelghafourzguindou picture abdelghafourzguindou  路  4Comments

semirturgay picture semirturgay  路  4Comments

sibelius picture sibelius  路  4Comments