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

placeholderTextColor not being set #100

Closed
luizParreira opened this issue Oct 23, 2018 · 12 comments
Closed

placeholderTextColor not being set #100

luizParreira opened this issue Oct 23, 2018 · 12 comments

Comments

@luizParreira
Copy link

Describe the bug
The placeholderTextColor is not being set whenever one wants to set a different placeholder text to the ones you want to display as values. Such as this:

screen shot 2018-10-23 at 17 58 28

To Reproduce

  1. Create a Picker component
  2. Change the placeholderTextColor
  3. Change the default placeholder to be a different value than the one displayed on items

Expected behavior
The placeholder text color should change to red. However, because of this line: https://github.com/lawnstarter/react-native-picker-select/blob/master/src/index.js#L193 the color attribute is never set.

Screenshots

screen shot 2018-10-23 at 18 07 02

  • Device: iOS Simulator
  • OS: iOS 12
  • react-native-picker-select version: 4.2.1
  • react-native version: 0.55.4
  • react version: 16.4.0

Reproduction and/or code sample
In order to reproduce the behaviour, just create the following component:

const placeholderTextColor = 'red';

const CustomPicker = () =>
  <Picker
    placeholderTextColor="red"
    placeholder={{label: 'Select an option', value: null}}
    doneText="Select"
    items={[{label: 'test 0', value: 0}, {label: 'test 1', value: 1}]}
    value={null}
    onValueChange={v => console.log(v)}
  />
@luizParreira luizParreira changed the title PlaceholderTextColor not being set placeholderTextColor not being set Oct 23, 2018
luizParreira added a commit to luizParreira/react-native-picker-select that referenced this issue Oct 23, 2018
- This PR fixes the bug that wouldn't set the `textPlaceholderColor` if
the `placeholder` label was not present on the `items` and was not
currewntly selected.
- The fix simply removes this condition, since I see no reason to have
this condition for this purpose. (Any thoughts?)
- Also, implement test cases for this use case

Closes: lawnstarter#100
luizParreira added a commit to luizParreira/react-native-picker-select that referenced this issue Oct 23, 2018
- This PR fixes the bug that wouldn't set the `textPlaceholderColor` if
the `placeholder` label was not present on the `items` and was not
currewntly selected.
- The fix simply removes this condition, since I see no reason to have
this condition for this purpose. (Any thoughts?)
- Also, implement test cases for this use case

Closes: lawnstarter#100
@lfkwtz
Copy link
Collaborator

lfkwtz commented Oct 24, 2018

Maybe I'm not understanding the issue here.

See the first use of the component here: https://snack.expo.io/rk1XLLpjQ

I added a placeholderTextColor, the placeholder itself is different from the default, and it works as I'm expecting it to. Are you expecting something different?

@luizParreira
Copy link
Author

@lfkwtz You are right. I was following the docs for version 5.0.0, but was using version 4.2.0, once I checked the releases, I notices that version 4.4.0 was when the placeholderTextColor got added. I updated the lib and it worked. My bad, sorry.

@lfkwtz
Copy link
Collaborator

lfkwtz commented Oct 24, 2018

All good. Glad it was an straightforward answer.

@Rajdeepc
Copy link

How to change placeholderTextColor in Android?

@NathanNovak
Copy link

@lfkwtz Changing the placeholderTextColor is still not working on iOS. Is there anything else that needs to be done since the info is not in the docs?

@lfkwtz
Copy link
Collaborator

lfkwtz commented Apr 23, 2020

look at the sample app

@noelq
Copy link

noelq commented May 1, 2020

@NathanNovak I did this and it works :


<RNPickerSelect style={pickerStyle} ... />


const pickerStyle = {
    inputIOS: {
        color: 'white',
        paddingHorizontal: 10,
        backgroundColor: 'red',
        borderRadius: 5,
    },
    placeholder: {
        color: 'white',
      },
    inputAndroid: {
        color: 'white',
        paddingHorizontal: 10,
        backgroundColor: 'red',
        borderRadius: 5,
    },
};

@raouf-madani
Copy link

@NathanNovak I did this and it works :


<RNPickerSelect style={pickerStyle} ... />

const pickerStyle = {
    inputIOS: {
        color: 'white',
        paddingHorizontal: 10,
        backgroundColor: 'red',
        borderRadius: 5,
    },
    placeholder: {
        color: 'white',
      },
    inputAndroid: {
        color: 'white',
        paddingHorizontal: 10,
        backgroundColor: 'red',
        borderRadius: 5,
    },
};

The issue is still persisting.

@rassmate
Copy link

I too have this issue, tried the above but with no luck

@skyshine999
Copy link

is this issue resolved, for me placeholderTextColor not working

@sumit-Espranza
Copy link

placeholder:{
color:"red",
}

// Add these lines in pickerSelectStyle

1 similar comment
@sumit-Espranza
Copy link

placeholder:{
color:"red",
}

// Add these lines in pickerSelectStyle

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 a pull request may close this issue.

9 participants