Skip to content

[List] Shouldn't hide when the component is controlled #5500

@starInEcust

Description

@starInEcust

Problem description

@davincho @oliviertassinari #4850

I found a bug in ListItem component.
set second item's props open = true, then click it to hide the third one. When hover the first ListItem, the second will reopen automatically;
I have read the source code and I found in line 421, handleMouseEnter will setState to change backgroundColor, but it will make child ListItem's componentWillReceiveProps setState according to it props in line 313

working code that reproduces the issue is

<List style={styles.menuStyle}>
                <ListItem
                    open
                    primaryText="1"
                    primaryTogglesNestedList
                    nestedItems={[
                        <ListItem
                            open
                            primaryText="2"
                            primaryTogglesNestedList
                            nestedItems={[
                                <ListItem
                                    primaryText="3"
                                />,
                            ]}
                        />,
                    ]}
                />
            </List>

Versions

  • Material-UI:^0.16.1
  • React:^15.2.1
  • Browser: chrome 53

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: listChanges related to the listtype: bugIt doesn't behave as expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions