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

Issue with using conditional disabled attribute on MenuItems #5

Closed
quicksnap opened this issue Mar 25, 2015 · 3 comments
Closed

Issue with using conditional disabled attribute on MenuItems #5

quicksnap opened this issue Mar 25, 2015 · 3 comments
Milestone

Comments

@quicksnap
Copy link

I have a requirement that selected MenuItems should appear disabled. I tried this:

        <MenuItem
          key={id}
          disabled={ id === this.state.selectedId } >
            {menuItemName}
        </MenuItem>

This causes issues on this line: https://github.com/react-component/menu/blob/master/lib/Menu.js#L155

since this code causes onDeselect not to be defined: https://github.com/react-component/menu/blob/master/lib/Menu.js#L218-L221

I've disabled the disabled check and it seems to fix my menu. Is this premature return necessary?

@yiminghe
Copy link
Member

it's an interesting use case: you can not deselect a selected disabled menuitem

http://react-component.github.io/menu/build/examples/multiple.html

@yiminghe yiminghe added this to the 3.1.0 milestone Mar 26, 2015
@quicksnap
Copy link
Author

Thanks for the fix! Curious, why the concat([]) call here?: 6204eb7#diff-5fbb3e2b7b0ae90b101ff557be1ad728R186

Are you cloning the this.state.selectedKeys to prevent referencing the original state object?

@yiminghe
Copy link
Member

yes, modify state/props directly is a bad practice (as react 0.13 emphasized), i didn't notice it before.

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

No branches or pull requests

2 participants