iulianraduat / react-select-material-ui

A react SELECT component based on react-select and looking like a material-ui component
MIT License
73 stars 18 forks source link

Support for placeholder text #2

Closed korshavn closed 5 years ago

korshavn commented 5 years ago

Hi. Would love if the select component could display a grey placeholder text..

image

In the picture above, the first input is a traditional Select (react-select). The second is with your library, and would prefer it. The others are just a free text and two date inputs.

I can see you have written "ignoring placeholder in SelectProps" in the doc. Is there a reason why?

Using together with redux-form :

` const renderReactSelectMaterialUIInput = (field) => { console.log("renderReactSelectMaterialUIInput", field); return <SingleSelect style={{width: "85%"}} SelectProps={{ placeholder: }} placeholder={} value={field.input.value} options={field.options} onChange={field.input.onChange} /> };

           ...

           <Field
              style={{width: "85%"}}
              name="conductor"
              component={renderReactSelectMaterialUIInput}
              value={this.state.selectedConductor}
              options={this.props.conductors}
              onChange={this.handleConductorChange}
            /><br/><br/>

`

Best regards, Leif John K.

korshavn commented 5 years ago

I will be using "selectrix" instead. Great work! :-)

iulianraduat commented 5 years ago

Feature request took into account :) I will check why I decided to ignore the placeholder and if it is possible I will add it. I will keep you posted 📬

iulianraduat commented 5 years ago

The placeholder was initially ignored as it can be overlapped by the label. Starting with version 1.2.1 you can use a placeholder as long as there is no label defined. To set the placeholder:

<SingleSelect
    style={{width: "85%"}}
    placeholder="--- your placeholder here ---"
    value={field.input.value}
    options={field.options}
    onChange={field.input.onChange}
/>

As you can see, you set it directly in the props of SingleSelect and not in SelectProps.placeholder Please check if it works as expected or it needs more improvements. Thanks.

korshavn commented 5 years ago

Thank you! It works. :-)

iulianraduat commented 5 years ago

I am happy that you are happy :smiley: