-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fixed] ListGroup
and ListGroupItem
output correct elements.
#467
Conversation
…efaults to <ul> if no ListGroupItem). ListGroupItem outputs <li> or <a> if href prop is set.
Thanks for jumping in on this, I had originally thrown that issue out there as a reminder for myself to dig into that more. I hadn't realized when I made that issue that Bootstrap supported both. I'm amazed at how much I learn something new everyday. Gaining this new insight I think we should do a little more here. Realistically the two options should not be mixed and matched. Which I believe is partly the reason for the
In this case what do we do? The first item suggests
Which produces: Issues to solve:
|
Should we wait for guidance on the bootstrap issue before going forward on this? |
For right now, I think as long as the first two issues are solved then we can bring this in. The main issue I see with your current implementation is that you only check the first child to see if it has an href, when you should check to see if any of the children do. Then when you are rending the parent with a |
I believe the first two issues are all set now.
If there are any other issues, let me know. |
if (child.props.href) { | ||
childrenAnchors = true; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Array.prototype.some here would be a little faster since it immediately returns on the first true result. Also slightly cleaner code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for Array.isArray(this.props.children)
The this.props.children
has opaque type and structure.
Consequently it can be subject to changes in future React releases.
Perhaps it would be more appropriate to use here React.Children API ?
…strap into fixListGroupEls Conflicts: src/ListGroupItem.js
Made the changes to use |
This looks great. I don't think we should worry too much about React.Children for now. If React changes things than we'll need to adjust but this will be faster for now. |
[fixed] `ListGroup` and `ListGroupItem` output correct elements.
Totally agree. Thank you @apkiernan. |
Fix for #460 -
ListGroup
outputs<ul>
or<div>
depending onListGroupItem
(defaults to<ul>
if noListGroupItem
).ListGroupItem
outputs<li>
by default, or<a>
if 'href' prop is set.