palantir/blueprint

[Table] wrapped table with onSelection listener doesn't allow select-all

Open

#1233 aperta il 14 giu 2017

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)TypeScript (2167 fork)batch import
P3Package: tableType: bughelp wanted

Metriche repository

Star
 (20.263 star)
Metriche merge PR
 (Merge medio 43g 10h) (27 PR mergiate in 30 g)

Descrizione

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 });
    };
}
  1. Click on the top-left-most header cell (the "select all" cell).

Actual behavior

  1. Selection does not change from it's current state.

Expected behavior

  1. 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).

Guida contributor