Material-ui: [ListItem] href property does not work for ListItems with button=true

Created on 27 Apr 2018  路  1Comment  路  Source: mui-org/material-ui


Want a list item to be a link. If I specify button={true} for a ListItem, would expect href attribute to work as it does within a Button. Instead, href property appears to do nothing in this context.

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior


For a ListItem with button={true}, would expect I could use href property to specify a link.

Current Behavior


If I specify a ListItem with button={true} and include an href property to specify a link, nothing happens when I click on the ListItem. I.e. href property doesn't work for ListItems, even when button={true}

Steps to Reproduce (for bugs)

1.
2.
3.
4.

Context

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | |
| React | |
| browser | |
| etc | |

List question

Most helpful comment

@srubin20170623 For the sake of HTML5 compliance, we force the button to render as a div. You need to force the rendering of a link:

      <ListItem button component="a" href="#option2">
        <ListItemText primary="Spam" />
      </ListItem>

https://codesandbox.io/s/4jkym3mq74

>All comments

@srubin20170623 For the sake of HTML5 compliance, we force the button to render as a div. You need to force the rendering of a link:

      <ListItem button component="a" href="#option2">
        <ListItemText primary="Spam" />
      </ListItem>

https://codesandbox.io/s/4jkym3mq74

Was this page helpful?
0 / 5 - 0 ratings

Related issues

revskill10 picture revskill10  路  3Comments

ericraffin picture ericraffin  路  3Comments

iamzhouyi picture iamzhouyi  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

chris-hinds picture chris-hinds  路  3Comments