mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-29 21:13:54 +03:00
Merge pull request #372 from danfooo/toggle-all
Add a label to the 'toggle-all' checkbox in todomvc
This commit is contained in:
commit
67a853bc4d
|
@ -15,10 +15,13 @@ export default class MainSection extends Component {
|
||||||
todos: PropTypes.array.isRequired,
|
todos: PropTypes.array.isRequired,
|
||||||
actions: PropTypes.object.isRequired
|
actions: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
// Keep a counter that can be used to create an html `id` attribute.
|
||||||
|
static mountCount = 0;
|
||||||
|
|
||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = { filter: SHOW_ALL };
|
this.state = { filter: SHOW_ALL };
|
||||||
|
this.htmlFormInputId = `toggle-all-${MainSection.mountCount++}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClearMarked() {
|
handleClearMarked() {
|
||||||
|
@ -57,12 +60,17 @@ export default class MainSection extends Component {
|
||||||
|
|
||||||
renderToggleAll(markedCount) {
|
renderToggleAll(markedCount) {
|
||||||
const { todos, actions } = this.props;
|
const { todos, actions } = this.props;
|
||||||
|
|
||||||
if (todos.length > 0) {
|
if (todos.length > 0) {
|
||||||
return (
|
return (
|
||||||
<input className='toggle-all'
|
<div>
|
||||||
|
<input id={this.htmlFormInputId}
|
||||||
|
className='toggle-all'
|
||||||
type='checkbox'
|
type='checkbox'
|
||||||
checked={markedCount === todos.length}
|
checked={markedCount === todos.length}
|
||||||
onChange={actions.markAll} />
|
onChange={actions.markAll} />
|
||||||
|
<label htmlFor={this.htmlFormInputId}>Mark all as complete</label>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user