mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +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) {
|
if (onChange) {
|
||||||
onChange(
|
onChange(changeInfo.pagination!, changeInfo.filters!, changeInfo.sorter!, {
|
||||||
changeInfo.pagination!,
|
currentDataSource: getFilterData(
|
||||||
changeInfo.filters!,
|
getSortData(rawData, changeInfo.sorterStates!, childrenColumnName),
|
||||||
changeInfo.sorter!,
|
changeInfo.filterStates!,
|
||||||
{
|
),
|
||||||
currentDataSource: getFilterData(
|
action,
|
||||||
getSortData(rawData, changeInfo.sorterStates!, childrenColumnName),
|
});
|
||||||
changeInfo.filterStates!,
|
|
||||||
),
|
|
||||||
action,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -409,7 +404,9 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Indent size
|
// Indent size
|
||||||
mergedExpandable.indentSize = mergedExpandable.indentSize || indentSize || 15;
|
if (typeof mergedExpandable.indentSize !== 'number') {
|
||||||
|
mergedExpandable.indentSize = typeof indentSize === 'number' ? indentSize : 15;
|
||||||
|
}
|
||||||
|
|
||||||
// ============================ Render ============================
|
// ============================ Render ============================
|
||||||
const transformColumns = React.useCallback(
|
const transformColumns = React.useCallback(
|
||||||
|
@ -40,10 +40,7 @@ const data = [
|
|||||||
describe('Table.expand', () => {
|
describe('Table.expand', () => {
|
||||||
it('click to expand', () => {
|
it('click to expand', () => {
|
||||||
const wrapper = mount(<Table columns={columns} dataSource={data} />);
|
const wrapper = mount(<Table columns={columns} dataSource={data} />);
|
||||||
wrapper
|
wrapper.find('.ant-table-row-expand-icon').last().simulate('click');
|
||||||
.find('.ant-table-row-expand-icon')
|
|
||||||
.last()
|
|
||||||
.simulate('click');
|
|
||||||
expect(wrapper.render()).toMatchSnapshot();
|
expect(wrapper.render()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,10 +56,7 @@ describe('Table.expand', () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapper
|
wrapper.find('.ant-table-row-expand-icon').first().simulate('click');
|
||||||
.find('.ant-table-row-expand-icon')
|
|
||||||
.first()
|
|
||||||
.simulate('click');
|
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find('.ant-table-row-expand-icon')
|
.find('.ant-table-row-expand-icon')
|
||||||
@ -70,10 +64,7 @@ describe('Table.expand', () => {
|
|||||||
.hasClass('ant-table-row-expand-icon-expanded'),
|
.hasClass('ant-table-row-expand-icon-expanded'),
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
|
|
||||||
wrapper
|
wrapper.find('.ant-table-row-expand-icon').first().simulate('click');
|
||||||
.find('.ant-table-row-expand-icon')
|
|
||||||
.first()
|
|
||||||
.simulate('click');
|
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find('.ant-table-row-expand-icon')
|
.find('.ant-table-row-expand-icon')
|
||||||
@ -96,6 +87,16 @@ describe('Table.expand', () => {
|
|||||||
expect(wrapper.find('.expand-icon')).toHaveLength(1);
|
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', () => {
|
describe('expandIconColumnIndex', () => {
|
||||||
it('basic', () => {
|
it('basic', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
@ -109,18 +110,8 @@ describe('Table.expand', () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(wrapper.find('td').at(0).text()).toEqual('bamboo');
|
||||||
wrapper
|
expect(wrapper.find('td').at(1).find('.ant-table-row-expand-icon').length).toBeTruthy();
|
||||||
.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', () => {
|
it('work with selection', () => {
|
||||||
@ -136,24 +127,9 @@ describe('Table.expand', () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(wrapper.find('td').at(0).find('.ant-checkbox-input').length).toBeTruthy();
|
||||||
wrapper
|
expect(wrapper.find('td').at(1).text()).toEqual('bamboo');
|
||||||
.find('td')
|
expect(wrapper.find('td').at(2).find('.ant-table-row-expand-icon').length).toBeTruthy();
|
||||||
.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