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

[SelectField] label bug #2446

Closed
cezarsmpio opened this issue Dec 9, 2015 · 33 comments
Closed

[SelectField] label bug #2446

cezarsmpio opened this issue Dec 9, 2015 · 33 comments
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module!

Comments

@cezarsmpio
Copy link

My code:

<SelectField
  hintText="Select the bicycle"
  menuItems={[
    { payload: 0, text: 'Bike 01' },
    { payload: 1, text: 'Bike 02' },
    { payload: 2, text: 'Bike 03' },
    { payload: 3, text: 'Bike 04' },
  ]}
/>

SelectField bug

drxxxhbreb

@justjacksonn
Copy link

You beat me to it.. I'd like to add..that in my case changing the selection does NOT remove the hint text.

@alitaheri alitaheri added bug 🐛 Something doesn't work Regression and removed bug 🐛 Something doesn't work labels Dec 9, 2015
@oliviertassinari
Copy link
Member

What version are you using? It seems that the issue is not present in the master branch.

@cezarsmpio
Copy link
Author

"material-ui": "^0.13.4"

@oliviertassinari
Copy link
Member

Could you try the master branch? This might be fixed.

@cezarsmpio
Copy link
Author

Use "0.14.0-rc1"?

@oliviertassinari
Copy link
Member

I would say master, we have recently changed the implementation of the SelectField.

@alitaheri alitaheri modified the milestone: 0.14.0 Release Dec 9, 2015
@cezarsmpio
Copy link
Author

Hi @oliviertassinari, I'm using 0.14.0-rc1 (npm version) and the problem wasn't fixed.

@alitaheri
Copy link
Member

@CezarLuiz0 Please wait for 0.14.0-rc2 and try again with that.

@bendiy
Copy link

bendiy commented Dec 17, 2015

See: #1427 (comment)
Make sure when onChange is set, value is also set. That might be related.

@alitaheri alitaheri modified the milestone: 0.14.0 Release Dec 22, 2015
@alitaheri
Copy link
Member

@CezarLuiz0 Is this fixed with the 0.14.0-rc2 or rather, master?

@oliviertassinari
Copy link
Member

I have just tried the examples of @CezarLuiz0 with the master branch. It's working correctly.

<SelectField
  hintText="Select the bicycle"
  menuItems={[
    { payload: 0, text: 'Bike 01' },
    { payload: 1, text: 'Bike 02' },
    { payload: 2, text: 'Bike 03' },
    { payload: 3, text: 'Bike 04' },
  ]}
/>

@cezarsmpio
Copy link
Author

Using 0.14.0-rc2 with npm, It was not fixed. Same problem here.

captura de tela 2015-12-23 as 08 55 02

captura de tela 2015-12-23 as 08 56 44

I will try use the master.

@cezarsmpio
Copy link
Author

Using npm install material-ui --save, the npm installed the version 0.13.4, same issue here.

-- edited

Using rc2
Example

@oliviertassinari
Copy link
Member

@CezarLuiz0 Can you share the SelectField source code?

@cezarsmpio
Copy link
Author

Sure!

    <SelectField
      hintText="Selecionar a bike"
      menuItems={[
        { payload: 0, text: 'Bike 01' },
        { payload: 1, text: 'Bike 02' },
        { payload: 2, text: 'Bike 03' },
        { payload: 3, text: 'Bike 04' },
      ]}
      fullWidth
    />

@oliviertassinari
Copy link
Member

Thanks, here is what I have:
dec 23 2015 12 18

How to you reflect the change of what the user is selecting?

@cezarsmpio
Copy link
Author

See my gif above, the selected item by the user changed, but for you, SelectField doesn't changed. My main problem is the label on the item and when I select an item, It doesn't get the selected color.

In documentation, SelectField works fine 😕

@oliviertassinari
Copy link
Member

I'm using the same source code than you. The result is completly different.
I don't understand, that must be on your side. Make sure your material-ui is currently installed.

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Dec 23, 2015
@oliviertassinari oliviertassinari removed this from the 0.14.0 Release milestone Dec 23, 2015
@cezarsmpio
Copy link
Author

Look my dependencies:

"dependencies": {
    "alt": "^0.18.0",
    "classnames": "^2.2.1",
    "flexboxgrid": "^6.3.0",
    "history": "^1.13.1",
    "lodash": "^3.10.1",
    "material-ui": "^0.14.0-rc2",
    "normalize.css": "^3.0.3",
    "react": "^0.14.0",
    "react-addons-css-transition-group": "^0.14.3",
    "react-addons-test-utils": "^0.14.0",
    "react-dom": "^0.14.0",
    "react-notification-system": "^0.2.6",
    "react-router": "^1.0.2",
    "react-tap-event-plugin": "^0.2.1",
    "react-toolbox": "^0.13.4",
    "rest-mapper": "^1.2.2"
  }

@oliviertassinari
Copy link
Member

Let's see what we have with 0.14.0-rc2:
dec 23 2015 13 00
So you were right 👍.

Still, this is what we have on the master branch:
dec 23 2015 13 04
Looks like the issue was solved 😄 .

@alitaheri
Copy link
Member

We'll release 0.14.0 very soon 😁 Check back after the release and see if it's fixed

@oliviertassinari Thanks for the confirmation 👍 👍

@rdagger
Copy link

rdagger commented Dec 27, 2015

I'm using 0.14.0 and I had a lot of trouble getting the SelectField to work. I was having the same problem with the label above. Here is an example of how I fixed it:

getInitialState(){
    return {
        selectValue: ''
    };
},

render() {
    const cats = ['Maine Coon','Siamese','Abyssinian','Sphynx','Himalayan','Bengal'];
    let categories = _.map(cats, function(cat, idx){ 
        return <MenuItem value={cat} key={idx} primaryText={cat}/>
        });
    return (
        <SelectField
            value={this.state.selectValue}
            onChange={this._handleSelectValueChange}
            floatingLabelText="Category">
            {categories}
        </SelectField>
    )
},

_handleSelectValueChange(event, index, value){
    this.setState({selectValue: value});
},

Key is necessary or else you get console warnings. PrimaryText is what is displayed in the DropDown. Value is necessary to avoid the label bug and make the field operate properly.
I'm not sure if this is the best practice. It is just what I figured out by trial and error.

Also, floatingLabelText and hintText cannot be used at the same time.

@alitaheri
Copy link
Member

@rdagger Thanks for the code example. Yeah I can confirm this issue. We'll try to look into it as soon as we can.

@rwoody
Copy link

rwoody commented Dec 29, 2015

@rdagger @alitaheri

Can confirm floatingLabelText and hintText cannot be used in conjunction. When I try, the floatingLabelText is displayed where the hintText would normally go, but clicking on it does nothing.

@cezarsmpio
Copy link
Author

Any solution? I'm using version 0.14.2 and the issue wasn't fixed.

Thanks!

@cezarsmpio
Copy link
Author

Hi guys, I'm using version 0.14.2:

2lugovfsrw

My component:

<SelectField
  floatingLabelText="Categoria"
  onChange={this.changeCategory}
  required
  fullWidth
>
  <MenuItem value={1} key={1} primaryText="Urbano" />
  <MenuItem value={2} key={2} primaryText="Ciclismo" />
  <MenuItem value={3} key={3} primaryText="Mountain Bike" />
</SelectField>

Any solution for this? Thanks guys!

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 20, 2016

@cezarlz A workaround is to provide a value property, have a look at the examples of the documentation. But that's definitely bug.

@cezarsmpio
Copy link
Author

Thanks! Is resolving my problem for while.

@tintin1343
Copy link
Contributor

@oliviertassinari : This is still happening on the docs website as well.

@nehalbhanushali
Copy link

any progress with this yet?

@oliviertassinari
Copy link
Member

As far as I have investigated, this issue is pretty related to #4275.

@MadeInMoon
Copy link

MadeInMoon commented Aug 11, 2016

@oliviertassinari
I still experiment this bug, without any link to #4275: looking the MenuItem values, there is no "null, undefined or empty values".
The problem happens when no SelectField value is given (still happens with material-ui@0.15.3 & react@15.3.0).

Component

        <SelectField               
          hintText  = {this.props.hintText}
          onChange  = {this.props.onChange}
          value  = {this.props.value}>

            {this.props.menuItems.map((item, i)=>{
               return <MenuItem key={i} value={'value'+i} primaryText={'primaryText'+1} label={'label'+i}/>
            })}

        </SelectField>  

2 Fixes possible

  • hintStyle
        <SelectField hintStyle = {{backgroundColor: '#ffffff', zIndex: 1, pointerEvents: 'none',  width: '85%'}}/>
  • CSS

Give a className

    <SelectField className="select" ... />

Target the hintText and add the following style

    .select{
      > div:first-child{
        background: white !important;          // same color as your page
        z-index: 1;                            // goes on top
        pointer-events: none;                  // don't block the click
        width: 85%,                            // be larger than the primaryTexts behind, but do not cover the little arraw on the right
      }
    }

@lucasbento lucasbento added the component: select This is the name of the generic UI component, not the React module! label Oct 15, 2016
@oliviertassinari oliviertassinari changed the title SelectField label bug [SelectField] label bug Jan 1, 2017
@jon-peel
Copy link

jon-peel commented Jul 7, 2018

I am having this problem with version 1.3.0

@mui mui locked as resolved and limited conversation to collaborators Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests