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

IconMenu with FlatButton unknown props warning #4857

Closed
slavab89 opened this issue Jul 30, 2016 · 5 comments · Fixed by #5496 or #5843
Closed

IconMenu with FlatButton unknown props warning #4857

slavab89 opened this issue Jul 30, 2016 · 5 comments · Fixed by #5496 or #5843
Labels
component: button This is the name of the generic UI component, not the React module! component: Icon The React component. v0.x

Comments

@slavab89
Copy link
Contributor

slavab89 commented Jul 30, 2016

Problem description

A warning when creating an IconMenu and putting a FlatButton as the iconButtonElement property

Steps to reproduce

I've tried to add the following icon menu (For a user account with its name near it)

<IconMenu
    iconButtonElement={
        <FlatButton
            icon={<AccountCircleIcon />} //Thats the svg icon
            label={'User Name'}
        />
    }
/>

Versions

  • Material-UI: 0.15.2
@tjunnone
Copy link
Contributor

tjunnone commented Aug 4, 2016

Same for IconMenu + RaisedButton with Material-UI 0.15.3:

<IconMenu iconButtonElement={<RaisedButton label="Test"/>}/>

The warning trace is:

Warning: Unknown prop iconStyle on tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
in button (created by EnhancedButton)
in EnhancedButton (created by RaisedButton)
in div (created by Paper)
in Paper (created by RaisedButton)
in RaisedButton (created by IconMenu)
in div (created by IconMenu)
in IconMenu

@carlgunderson
Copy link

I'm still seeing the warnings in version 0.15.3 for disabledBackgroundColor and disabledLabelColor properties of the RaisedButton component.

@tpmh31292
Copy link

react-unknown-props for disabledBackgroundColor and disabledLabelColor properties of the RaisedButton component.

v15.3.0

@jpellizzari
Copy link

jpellizzari commented Nov 1, 2016

The root cause of this issue appears to be the merging of the iconStyle prop with the same prop of the iconElement that is being passed as a prop.

https://github.com/callemall/material-ui/blob/master/src/IconMenu/IconMenu.js#L272

    const iconButton = React.cloneElement(iconButtonElement, {
      onKeyboardFocus: onKeyboardFocus,
      iconStyle: Object.assign({}, iconStyle, iconButtonElement.props.iconStyle), // <--
      onTouchTap: (event) => {
        this.open(Events.isKeyboard(event) ? 'keyboard' : 'iconTap', event);
        if (iconButtonElement.props.onTouchTap) {
          iconButtonElement.props.onTouchTap(event);
        }
      },
      ref: 'iconButton',
    });

The Object.assign() call is passing an object as the iconStyle prop to the iconButton element, which will then pass it all the way down to the <button />.

A proposed fix would be to only try to merge the styles if iconButtonElement has an iconStyle prop defined. Something like this:

if (iconButtonElement.props.iconStyle) {
  iconButton.props.iconStyle = Object.assign({}, iconStyle, iconButtonElement.props.iconStyle);
}

@slavab89
Copy link
Contributor Author

Sorry to bring this up again but this still seems to happen (for me)
Happens with the above steps to reproduce and the following example

import AccountCircleIcon from 'material-ui/svg-icons/action/account-circle';

<IconMenu
    iconButtonElement={
        <FlatButton
            icon={<AccountCircleIcon />} //Thats the svg icon
            label={'User Name'}
            style={{color: 'white'}}
        />
    }
/>

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 21, 2022
@zannager zannager added component: Icon The React component. component: button This is the name of the generic UI component, not the React module! v0.x and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! component: Icon The React component. v0.x
Projects
None yet
7 participants