palantir/blueprint
View on GitHub[Table] wrapped table with onSelection listener doesn't allow select-all
Open
#1,233 opened on Jun 14, 2017
P3Package: tableType: bughelp wanted
Description
Bug report
- Package version(s): core: 1.17.1, table: 1.17.0
- Browser and OS versions: Chrome 58.0.3029.110, OS X 10.12.5
Steps to reproduce
Using this table-containing component:
interface State {
selection: IRegion[];
}
export class BuggyTable extends React.PureComponent<{}, State> {
public state: State = {
selection: [],
};
public render() {
return (
<Table
numRows={1}
selectionModes={SelectionModes.ALL}
onSelection={this.updateSelection}
>
<Column
name="foo"
renderCell={(rowIndex) => <Cell>bar</Cell>}
/>
</Table>
);
}
private updateSelection = (selection: IRegion[]) => {
this.setState({ selection });
};
}
- Click on the top-left-most header cell (the "select all" cell).
Actual behavior
- Selection does not change from it's current state.
Expected behavior
- Selection is set to "all cells".
Commenting out the this.setState line causes selection to behave as expected again. Wrapping this.setState in a zero-duration setTimeout also causes selection to behave as expected. Looks like some kind of synchronicity/deferral issue?
Confusingly, all other types of selection work (entire-row, entire-column, single-cell, multiple-cell).