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

React .14 warns <a> cannot be descendant of <a> #1979

Closed
TrySpace opened this issue Oct 23, 2015 · 3 comments
Closed

React .14 warns <a> cannot be descendant of <a> #1979

TrySpace opened this issue Oct 23, 2015 · 3 comments
Labels
bug 🐛 Something doesn't work

Comments

@TrySpace
Copy link
Contributor

I'm nesting an IconMenu inside a ListItem:
Now both use EnhancedButton which generates an <a> tag around their children

iconButton = <IconButton>more</IconButton>
iconMenu = (  <IconMenu iconButtonElement={iconButton}>
                <MenuItem primaryText="Remove" onTouchTap={@removeItem} />
              </IconMenu>
)                  

<ListItem
   rightIconButton={iconMenu}>

</ListItem>

Which will give this warning:
cannot appear as a descendant of . See MessageItem > ListItem > EnhancedButton > a > ... > IconMenu > ReactTransitionGroup > Menu > MenuItem > ListItem > EnhancedButton > a

Because, I'm assuming the HTML spec does not allow this. Which is kind of logical, why would you put an anchor inside an anchor. But either it's the spec that is outdated, but moreover we are using html for things it was not meant for.

Now, I don't think there is any way around this warning, other than to not have the EnhancedButton have an anchor-tag around it.
Which wouldn't be bad if it's not using any href?

Maybe make it a span when linkButton === false ?

@chitopolo
Copy link

I'm trying to deal with the same issue, i hope to get an answer soon, or if you got it please let me know! ;) Best Regards.

@TrySpace
Copy link
Contributor Author

TrySpace commented Nov 6, 2015

"So I think the real issue is that we have no support for nested menus yet." Someone replied, but the comment is gone.

I agree, and we should use the EnhancedButton as a Menu/ListItem. Rather use the touchRipple from the button an add it to an item. Thus avoiding anchor-tags.

Nested / Composable Components would be the best solution here. But that's being worked on across the board, as I understand it.

@alitaheri alitaheri added the bug 🐛 Something doesn't work label Dec 9, 2015
@alitaheri alitaheri added this to the Composable Components milestone Dec 9, 2015
@alitaheri alitaheri modified the milestones: Composable Components, 0.14.1 Release Dec 23, 2015
alitaheri added a commit to alitaheri/material-ui that referenced this issue Dec 29, 2015
This has caused many issues, when an <a> element is created in this component there will be no way to support links, as nested <a> elements is offensive in the eyes of HTML.

Closes mui#2178, mui#1979, mui#1823
alitaheri added a commit to alitaheri/material-ui that referenced this issue Dec 30, 2015
This has caused many issues, when an <a> element is created in this component there will be no way to support links, as nested <a> elements is offensive in the eyes of HTML.

Closes mui#2178, mui#1979, mui#1823
@alitaheri
Copy link
Member

Fixed in #2708

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

No branches or pull requests

3 participants