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

[ListItem] how to support SubItem #1105

Closed
cgestes opened this issue Jul 10, 2015 · 6 comments · Fixed by #1438
Closed

[ListItem] how to support SubItem #1105

cgestes opened this issue Jul 10, 2015 · 6 comments · Fixed by #1438
Labels
component: list This is the name of the generic UI component, not the React module!

Comments

@cgestes
Copy link
Contributor

cgestes commented Jul 10, 2015

Follow up of the discussion here: https://github.com/callemall/material-ui/pull/1096/files#r34335985

How can we distinguish between SubItem and child in ListItem?

The current issue is the following:

var FooItem = React.createComponent({
  render(): { return <ListItem.../>; }
}

<ListItem>
  <FooItem>
</ListItem>

How can we know that FooItem is a subitem?

I see multiples solutions:

  • Use NestedItem:
<ListItem>
  <Whatever child>
  <NestedItem>
    whatever nested items
  </NestedItem>
</ListItem>
  • Consider all childs as subitem and always use primaryText for ListItem content
  • Use deep child traversal to find deep nested ListItem
    I see special case where ones would want a child with a List.
  • Use a property on the parent ListItem to specify it has subitems

What do you think?

@cgestes cgestes changed the title [ListItem] how to support Su [ListItem] how to support SubItem Jul 10, 2015
@cgestes
Copy link
Contributor Author

cgestes commented Jul 17, 2015

Or we can simply use context to give the nested level to childrens.

It seems cleaner but it has the drawback that context are going to change in React, but I guess we will be able to adapt so it should not be an issue.

@brennanreese
Copy link

Does this break nested ListItem's ? I am trying to use the basic example from the docs page and am getting this error:

Uncaught Error: Invariant Violation: ReactMount: Two valid but unequal nodes with the same data-reactid: .0.1.1:1

I'm not even adding anything special to it. Just the straight up example from the docs. What am I missing here?

@hai-cea
Copy link
Member

hai-cea commented Jul 30, 2015

It looks like ListItem is generating a ListNested here - https://github.com/callemall/material-ui/blob/master/src/lists/list-item.jsx#L270

The down side to this is that it's having to traverse all of the children and pick out ListItems as you've mentioned @cgestes. Also, this a performance problem since it will have to look at all children in order to know if there are any nested list items.

I propose that we create a new prop called nestedList and also rename ListNested to NestedList. Here's how it would work:

<List subheader="Nested List Items">
  <ListItem primaryText="Sent mail" leftIcon={<ContentSend />} />
  <ListItem primaryText="Drafts" leftIcon={<ContentDrafts />} />
  <ListItem primaryText="Inbox" leftIcon={<ContentInbox />} open={true} nestedList={
    <NestedList>
      <ListItem primaryText="Starred" leftIcon={<ActionGrade />} />
      <ListItem primaryText="Sent Mail" leftIcon={<ContentSend />} nestedList={
        <NestedList>
          <ListItem primaryText="Drafts" leftIcon={<ContentDrafts />} />
        </NestedList>
      }/>
    </NestedList>
  }/>
</List>

What do you guys think? @oliviertassinari @jkruder @cgestes

@jkruder
Copy link
Contributor

jkruder commented Jul 30, 2015

@hai-cea This was how the initial nested list items was done, passed as props. We could use a property to indicate that it has children and then we can wrap all children in a ListNested component. Note that this would still require searching all children but we would only be doing that if the LiatItem has property indicating it has children.

@hai-cea
Copy link
Member

hai-cea commented Aug 17, 2015

@cgestes @jkruder I made PR to address this issue - #1438. Please let me know what you think.

@cgestes
Copy link
Contributor Author

cgestes commented Aug 18, 2015

Sorry on hollidays.

What do you think about using context instead of nestedItem to propagate
nested level and stick to a component hierarchy like in html?

On Tue, Aug 18, 2015, 00:54 Hai Nguyen notifications@github.com wrote:

@cgestes https://github.com/cgestes @jkruder
https://github.com/jkruder I made PR to address this issue - #1438
#1438. Please let me know
what you think.


Reply to this email directly or view it on GitHub
#1105 (comment)
.

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

Successfully merging a pull request may close this issue.

6 participants