mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [table-v2] respect column flexShrink configuration (#22914)
closed #22913 Co-authored-by: alex.yang <alex.yang@hytechc.com> Co-authored-by: 云游君 <me@yunyoujun.cn>
This commit is contained in:
@@ -188,6 +188,46 @@ describe('TableV2.vue', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('respects column flexShrink = 0', async () => {
|
||||
const columns = ref([
|
||||
{
|
||||
key: 'col-0',
|
||||
dataKey: 'col-0',
|
||||
title: 'Col 0',
|
||||
width: 200,
|
||||
flexShrink: 0,
|
||||
},
|
||||
{
|
||||
key: 'col-1',
|
||||
dataKey: 'col-1',
|
||||
title: 'Col 1',
|
||||
width: 200,
|
||||
flexShrink: 0,
|
||||
},
|
||||
])
|
||||
const data = ref([
|
||||
{
|
||||
id: 'row-0',
|
||||
'col-0': 'Row 0 - Col 0',
|
||||
'col-1': 'Row 0 - Col 1',
|
||||
},
|
||||
])
|
||||
|
||||
const wrapper = mount(() => (
|
||||
<TableV2
|
||||
columns={columns.value}
|
||||
data={data.value}
|
||||
width={300}
|
||||
height={200}
|
||||
/>
|
||||
))
|
||||
|
||||
const rowCells = wrapper.findAll('.el-table-v2__row-cell')
|
||||
expect(rowCells.length).toBeGreaterThanOrEqual(2)
|
||||
expect(rowCells[0].attributes('style')).toContain('flex-shrink: 0;')
|
||||
expect(rowCells[1].attributes('style')).toContain('flex-shrink: 0;')
|
||||
})
|
||||
|
||||
test('expandable mode wrongly enabled, by column not key', async () => {
|
||||
const columns = ref([
|
||||
{
|
||||
|
||||
@@ -12,15 +12,11 @@ export const calcColumnStyle = (
|
||||
...(fixed
|
||||
? {}
|
||||
: {
|
||||
flexGrow: column.flexGrow || 0,
|
||||
flexShrink: column.flexShrink || 1,
|
||||
flexGrow: column.flexGrow ?? 0,
|
||||
flexShrink: column.flexShrink ?? 1,
|
||||
}),
|
||||
}
|
||||
|
||||
if (!fixed) {
|
||||
flex.flexShrink = 1
|
||||
}
|
||||
|
||||
const style = {
|
||||
...(column.style ?? {}),
|
||||
...flex,
|
||||
|
||||
Reference in New Issue
Block a user