-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[List/ListItem] Introduce selected property #1581 #1976
Conversation
Is there anything I can do to get this merged? |
|
||
const styles = { | ||
root: { | ||
backgroundColor: (this.state.isKeyboardFocused || this.state.hovered) && | ||
backgroundColor: (this.props.selected && !this.state.hovered) ? selectedColor : ((this.state.isKeyboardFocused || this.state.hovered) && |
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.
the ...other
is going to have the selected
property then passed to the EnhancedButton
. Is this intentional? Otherwise, can you remove it.
I've set the default value as suggested and fixed the unintentionally passing of |
@@ -85,16 +88,39 @@ const List = React.createClass({ | |||
subheaderElement = <div style={mergedSubheaderStyles}>{subheader}</div>; | |||
} | |||
|
|||
let listItems = React.Children.map(children, (child) => { | |||
if ( this.props.selectedLink && (child.type.displayName === "ListItem") ) { |
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.
I would move if(this.props.selectedLink
out of the loop, for perf reasons. What do you think?
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.
I fully agree.
@frankf-cgn Thanks. Could you have a look at my feedbacks? I think that this PR is going in the right direction 👍. I will also ask you to squash down the number of commit (to 2 or 3). I will keep the history clean. |
@oliviertassinari Thanks for your review and time. I fixed the loop and I'll do the documentation stuff. And of cource I'm going to shrink down the number of commits. |
@oliviertassinari I have fixed the loop and added the documentation. Concerning the documentation I have tried to choose the wording to be close to the tabs-stuff cos it's somehwat similar to this. Let me know if you are fine with it and I'll clean up the commit history and rebase to the current master. |
c475b9b
to
9782ec6
Compare
@oliviertassinari Squashed the commits |
9782ec6
to
006a180
Compare
@oliviertassinari If you are ready to merge this, come back to me and I will rebase to the actual master. |
} | ||
|
||
handleUpdateSelectedIndex = (index) => { | ||
this.setState(Object.assign({}, this.state, {selectedIndex: index})); |
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.
Why not doing?
this.setState({
selectedIndex: index,
});
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.
The way I proposed to set the state ensures that whatever is currently in the state does not get overwritten / thrown away unintentionally, isn't it?
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 far as I know, we have the same result with the above. See the setState doc:
Performs a shallow merge of nextState into current state
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.
Uups, didn't rember that. So I'll change it.
@oliviertassinari Thanks for the hints. I have incorporated your suggestions. |
Sounds like a good idea |
006a180
to
4e1d559
Compare
@oliviertassinari OK to merge? |
@shaurya947 I didn't try it but it looks good to me. |
</Paper> | ||
); | ||
}, | ||
|
||
_getSelected(index) { |
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.
Not sure we need to create two methods since they are called at only one place.
@oliviertassinari I think you should check it out before you merge since you've reviewed the code (and are more familiar with it). |
I wasn't going to merge yet 😁 |
Well, eventually, right? :-P |
@@ -54,6 +85,12 @@ export default class ListsPage extends React.Component { | |||
desc: 'If true, the subheader will be indented by 72px.', | |||
}, | |||
{ | |||
name: 'selectedItemStyle', | |||
type: 'object', | |||
header: 'optional, only available it HOC SelectableContainerEnhance is used', |
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.
only available if HOC
@frankf-cgn thus far we've used simple html tags with some |
ec3b30e
to
1e04820
Compare
The typos are fixed, some rewording has taken place and I have removed the markdown stuff. Hope we have reached the last itterations ;-) |
<ul> | ||
<li> enhance <code><List></code> with HOC</li> | ||
<li> decide where to put state</li> | ||
<li> implement end set valueLink</li> |
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.
should this read "implement and set valueLink" ?
I just pointed out a few quick things @frankf-cgn. Once you can take care of them, we should merge this. I'll also give @oliviertassinari a chance to look over this. |
1e04820
to
a47a59e
Compare
@shaurya947 I was so sure that I have find all typos during my proofreading. Ok, everthing done by now and pushed. |
@shaurya947 Let's see |
</p> | ||
<div style={styles.codeblock}> | ||
<CodeBlock> | ||
{`import { SelectableContainerEnhance } from 'material-ui/hoc/selectable-enhance'; |
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.
missing lib/
?
a47a59e
to
f76b83b
Compare
[List/ListItem] Introduce selected property #1581
@frankf-cgn Thank you! |
@oliviertassinari @shaurya947 I have to thank you both! |
Yay! Great job @frankf-cgn |
Implementation of Issue #1581:
Example implementation for the container component for the List: