mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
fix: The 'indentSize' in the Table component couldn't be zero value (#25890)
* - Fixed the indentSize prop of Table.tsx to also accept 0 values * - Undo Cascader component test snapshots * - Added test case - Used check with typeof === number instead of `undefined` and `null` Co-authored-by: omri.g <omri.g@alibaba-inc.com>
This commit is contained in:
parent
36ec093962
commit
8800b56e47
@ -222,18 +222,13 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
|
||||
}
|
||||
|
||||
if (onChange) {
|
||||
onChange(
|
||||
changeInfo.pagination!,
|
||||
changeInfo.filters!,
|
||||
changeInfo.sorter!,
|
||||
{
|
||||
currentDataSource: getFilterData(
|
||||
getSortData(rawData, changeInfo.sorterStates!, childrenColumnName),
|
||||
changeInfo.filterStates!,
|
||||
),
|
||||
action,
|
||||
},
|
||||
);
|
||||
onChange(changeInfo.pagination!, changeInfo.filters!, changeInfo.sorter!, {
|
||||
currentDataSource: getFilterData(
|
||||
getSortData(rawData, changeInfo.sorterStates!, childrenColumnName),
|
||||
changeInfo.filterStates!,
|
||||
),
|
||||
action,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -409,7 +404,9 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
|
||||
}
|
||||
|
||||
// Indent size
|
||||
mergedExpandable.indentSize = mergedExpandable.indentSize || indentSize || 15;
|
||||
if (typeof mergedExpandable.indentSize !== 'number') {
|
||||
mergedExpandable.indentSize = typeof indentSize === 'number' ? indentSize : 15;
|
||||
}
|
||||
|
||||
// ============================ Render ============================
|
||||
const transformColumns = React.useCallback(
|
||||
|
@ -40,10 +40,7 @@ const data = [
|
||||
describe('Table.expand', () => {
|
||||
it('click to expand', () => {
|
||||
const wrapper = mount(<Table columns={columns} dataSource={data} />);
|
||||
wrapper
|
||||
.find('.ant-table-row-expand-icon')
|
||||
.last()
|
||||
.simulate('click');
|
||||
wrapper.find('.ant-table-row-expand-icon').last().simulate('click');
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -59,10 +56,7 @@ describe('Table.expand', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
wrapper
|
||||
.find('.ant-table-row-expand-icon')
|
||||
.first()
|
||||
.simulate('click');
|
||||
wrapper.find('.ant-table-row-expand-icon').first().simulate('click');
|
||||
expect(
|
||||
wrapper
|
||||
.find('.ant-table-row-expand-icon')
|
||||
@ -70,10 +64,7 @@ describe('Table.expand', () => {
|
||||
.hasClass('ant-table-row-expand-icon-expanded'),
|
||||
).toBeTruthy();
|
||||
|
||||
wrapper
|
||||
.find('.ant-table-row-expand-icon')
|
||||
.first()
|
||||
.simulate('click');
|
||||
wrapper.find('.ant-table-row-expand-icon').first().simulate('click');
|
||||
expect(
|
||||
wrapper
|
||||
.find('.ant-table-row-expand-icon')
|
||||
@ -96,6 +87,16 @@ describe('Table.expand', () => {
|
||||
expect(wrapper.find('.expand-icon')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('row indent padding should be 0px when indentSize defined as 0', () => {
|
||||
const wrapper = mount(<Table indentSize={0} columns={columns} dataSource={data} />);
|
||||
const button = wrapper.find('.ant-table-row-expand-icon').at(0);
|
||||
button.simulate('click');
|
||||
expect(wrapper.find('.indent-level-1').at(0).prop('style')).toHaveProperty(
|
||||
'paddingLeft',
|
||||
'0px',
|
||||
);
|
||||
});
|
||||
|
||||
describe('expandIconColumnIndex', () => {
|
||||
it('basic', () => {
|
||||
const wrapper = mount(
|
||||
@ -109,18 +110,8 @@ describe('Table.expand', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
wrapper
|
||||
.find('td')
|
||||
.at(0)
|
||||
.text(),
|
||||
).toEqual('bamboo');
|
||||
expect(
|
||||
wrapper
|
||||
.find('td')
|
||||
.at(1)
|
||||
.find('.ant-table-row-expand-icon').length,
|
||||
).toBeTruthy();
|
||||
expect(wrapper.find('td').at(0).text()).toEqual('bamboo');
|
||||
expect(wrapper.find('td').at(1).find('.ant-table-row-expand-icon').length).toBeTruthy();
|
||||
});
|
||||
|
||||
it('work with selection', () => {
|
||||
@ -136,24 +127,9 @@ describe('Table.expand', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
wrapper
|
||||
.find('td')
|
||||
.at(0)
|
||||
.find('.ant-checkbox-input').length,
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
wrapper
|
||||
.find('td')
|
||||
.at(1)
|
||||
.text(),
|
||||
).toEqual('bamboo');
|
||||
expect(
|
||||
wrapper
|
||||
.find('td')
|
||||
.at(2)
|
||||
.find('.ant-table-row-expand-icon').length,
|
||||
).toBeTruthy();
|
||||
expect(wrapper.find('td').at(0).find('.ant-checkbox-input').length).toBeTruthy();
|
||||
expect(wrapper.find('td').at(1).text()).toEqual('bamboo');
|
||||
expect(wrapper.find('td').at(2).find('.ant-table-row-expand-icon').length).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user