-
Notifications
You must be signed in to change notification settings - Fork 840
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
Fix EuiTableOfRecords selection bug when selected items are deleted #365
Conversation
66ec432
to
6345ad8
Compare
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.
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) { |
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.
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 |
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.
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" |
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.
what's that?
@@ -479,13 +503,13 @@ export class EuiTableOfRecords extends React.Component { | |||
checked={checked} | |||
onChange={onChange} | |||
title={title} | |||
data-test-subj={`checkboxSelectRow-${recordId}`} |
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.
and that?
55d770f
to
e551b90
Compare
e551b90
to
e34e154
Compare
Fixed two bugs: