palantir/blueprint

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

開放

#1,233 建立於 2017年6月14日

 (2 則留言) (0 個反應) (0 位負責人)TypeScript (2,167 個分叉)batch import
P3Package: tableType: bughelp wanted

倉庫指標

星標
 (20,263 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南