mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
fix additional className (#14770)
This commit is contained in:
parent
57f4c62368
commit
67ad35bc26
@ -208,6 +208,10 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
|
||||
this.store.setState({
|
||||
selectedRowKeys: nextProps.rowSelection.selectedRowKeys || [],
|
||||
});
|
||||
} else if (this.props.rowSelection && !nextProps.rowSelection) {
|
||||
this.store.setState({
|
||||
selectedRowKeys: [],
|
||||
});
|
||||
}
|
||||
if ('dataSource' in nextProps && nextProps.dataSource !== this.props.dataSource) {
|
||||
this.store.setState({
|
||||
|
@ -651,4 +651,17 @@ describe('Table.rowSelection', () => {
|
||||
checkboxes.at(2).simulate('change', { target: { checked: true } });
|
||||
expect(checkboxAll.instance().state).toEqual({ indeterminate: false, checked: true });
|
||||
});
|
||||
|
||||
it('clear selection className when remove `rowSelection`', () => {
|
||||
const dataSource = [{ id: 1, name: 'Hello', age: 10 }, { id: 2, name: 'World', age: 30 }];
|
||||
|
||||
const wrapper = mount(<Table columns={columns} dataSource={dataSource} rowSelection={{}} />);
|
||||
const checkboxes = wrapper.find('input');
|
||||
checkboxes.at(1).simulate('change', { target: { checked: true } });
|
||||
|
||||
expect(wrapper.find('.ant-table-row-selected').length).toBe(1);
|
||||
|
||||
wrapper.setProps({ rowSelection: null });
|
||||
expect(wrapper.find('.ant-table-row-selected').length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user