peacechen / react-native-modal-selector

A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.
MIT License
369 stars 129 forks source link

selectTextStyle has no effect #119

Closed greenais closed 5 years ago

greenais commented 5 years ago

Passing style to selectTextStyle prop has no effect for me in the most recent version. Text stays small and gray. In previous version (1.0.3) same code worked.

Used in default mode:


      <ModalSelector
                data={countries}
                initValue={this.state.countryName}
                onChange={this._handleCountry}
                selectStyle={styles.selectStyle}
                selectTextStyle={styles.selectText}
                optionContainerStyle={styles.optionContainerStyle}
                optionStyle={styles.optionStyle}
                optionTextStyle={styles.optionText}
                cancelText={t.general.cancel}
                cancelStyle={styles.cancelStyle}
                cancelTextStyle={styles.cancelTextStyle}
              />
         ...
 const styles = StyleSheet.create({
...
selectText: {
    fontSize: 18,
    color: '#000000',
  },
...
})

"react-native": "0.60.5", "react-native-modal-selector": "1.1.1",

Any suggestions, perhaps?

mikaello commented 5 years ago

I can not reproduce this with Expo snack. When I set selectTextStyle={{ color: "red" }}, the color is changed to red when I select an item in the modal: https://snack.expo.io/@mikaello/selecttextstyle-demo

selectstyle

Can you please provide a minimal example reproducing the behaviour?

peacechen commented 5 years ago

1.1.0 introduced a change that may have affected this. Previously, selectTextStyle applied all the time, but the recent change applies the style only on selection. https://github.com/peacechen/react-native-modal-selector/blob/75a31d0cd12a152d445e9d6051d47d353b2baf44/index.js#L277

This was done for the new initValueTextStyle prop. It looks like a regression.

greenais commented 5 years ago

@mikaello I don't use Expo, my project is pure RN with debugging in Android simulator. Tested release bundle on several real devices - all the same: text style props has no effect. I was surprised when saw this change in my UI after upgrade - thought that there were some changes in API, but when checked - no changes. Code is as provided above - just copypaste form my IDE. Other style props work as expected, no changes. BTW, style remains the same even after selecting item in modal. Style isn't applied before and after selection - remains the same Image 2 .

peacechen commented 5 years ago

@greenais Would you try using the initValueTextStyle prop?

greenais commented 5 years ago

@peacechen initValueTextStyle works, thank you! My issue solved. selectTextStyle has no effect still, I even removed it completely