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

Fix EuiTableOfRecords selection bug when selected items are deleted #365

Merged
merged 3 commits into from
Feb 5, 2018

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Feb 2, 2018

Fixed two bugs:

  1. Deleting selected items now resets the select all checkbox to an unchecked state
  2. The select all checkbox only becomes checked when all selectable rows are checked, not just some of them

@cjcenizal cjcenizal force-pushed the bug/table-all-selected-checkbox branch from 66ec432 to 6345ad8 Compare February 3, 2018 05:43
Copy link
Contributor

@uboness uboness left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments & questions

onDataCriteriaChange(criteria) {
this.setState(this.computeTableState(criteria));
}

deletePerson(personToDelete) {
const i = people.findIndex((person) => person.id === personToDelete.id);
if (i >= 0) {
if (i !== -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while both work, i >= 0 makes more sense (or i > -1 also works)

@@ -235,6 +235,25 @@ export class EuiTableOfRecords extends React.Component {
this.setState({ hoverRecordId: null });
}

componentWillReceiveProps(nextProps) {
// Don't call changeSelection here or else we can get into an infinite loop:
// changeSelection calls owner -> owner sets its state -> we receive new props -> ad infinitum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's "owner"... I think the reason for this is that the changeSelection also calls onSelectionChange if one is provided... and that one may change the props.... I think we should be clear about it

headers.push(
<EuiTableHeaderCellCheckbox key="_selection_column_h" width="24px">
<EuiCheckbox
id="_selection_column-checkbox"
type="inList"
checked={checked}
onChange={onChange}
data-test-subj="checkboxSelectAll"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's that?

@@ -479,13 +503,13 @@ export class EuiTableOfRecords extends React.Component {
checked={checked}
onChange={onChange}
title={title}
data-test-subj={`checkboxSelectRow-${recordId}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and that?

@cjcenizal cjcenizal force-pushed the bug/table-all-selected-checkbox branch from 55d770f to e551b90 Compare February 5, 2018 20:13
@cjcenizal cjcenizal force-pushed the bug/table-all-selected-checkbox branch from e551b90 to e34e154 Compare February 5, 2018 20:15
@cjcenizal cjcenizal merged commit 6a9d9c0 into elastic:master Feb 5, 2018
@cjcenizal cjcenizal deleted the bug/table-all-selected-checkbox branch February 5, 2018 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants