-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Table] Fixing selectAll functionality a bit #4589
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,11 @@ class TableBody extends Component { | |
}; | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if (this.props.allRowsSelected && !nextProps.allRowsSelected) { | ||
if (!this.props.allRowsSelected && nextProps.allRowsSelected) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to clear out the selected state within the component when the |
||
this.setState({ | ||
selectedRows: [], | ||
}); | ||
} else if (this.props.allRowsSelected && !nextProps.allRowsSelected) { | ||
this.setState({ | ||
selectedRows: this.state.selectedRows.length > 0 ? | ||
[this.state.selectedRows[this.state.selectedRows.length - 1]] : [], | ||
|
@@ -139,7 +143,7 @@ class TableBody extends Component { | |
} | ||
|
||
handleClickAway = () => { | ||
if (this.props.deselectOnClickaway && this.state.selectedRows.length) { | ||
if (this.props.deselectOnClickaway && (this.state.selectedRows.length || this.props.allRowsSelected)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we clear the selectedRows when |
||
this.setState({ | ||
selectedRows: [], | ||
}); | ||
|
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.
Here we are allowing for the maintaining of allRowsSelected from outside of the component. This is necessary if utilizing "selected" on the data.
When maintaining the "selected" state outside of the table, you should expect to have to maintain the "all selected" state as well I believe.