palantir/blueprint

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

Open

#1,233 创建于 2017年6月14日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)TypeScript (20,263 star) (2,167 fork)batch import
P3Package: tableType: bughelp wanted

描述

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

贡献者指南