fix: optimize table overflow and action widths
This commit is contained in:
@@ -12,8 +12,8 @@ const TableStub = defineComponent({
|
||||
})
|
||||
const ColumnStub = defineComponent({
|
||||
inheritAttrs: false,
|
||||
props: { label: String, prop: String, fixed: [String, Boolean], showOverflowTooltip: Boolean },
|
||||
template: '<div class="column-stub" :data-label="label" :data-prop="prop" :data-fixed="String(fixed || \'\')" :data-overflow-tooltip="String(showOverflowTooltip)"><slot /></div>',
|
||||
props: { label: String, prop: String, fixed: [String, Boolean], showOverflowTooltip: Boolean, className: String },
|
||||
template: '<div class="column-stub" :data-label="label" :data-prop="prop" :data-fixed="String(fixed || \'\')" :data-overflow-tooltip="String(showOverflowTooltip)" :data-class-name="className"><slot /></div>',
|
||||
})
|
||||
const ButtonStub = defineComponent({ template: '<button type="button"><slot /></button>' })
|
||||
const PopoverStub = defineComponent({ template: '<div><slot name="reference" /><slot /></div>' })
|
||||
@@ -152,6 +152,36 @@ describe('DataTable column preferences', () => {
|
||||
expect(wrapper.get('.data-table__pagination').text()).toContain('共 0 条')
|
||||
})
|
||||
|
||||
it('keeps ordinary cells on one line with overflow tooltips and exempts system columns', () => {
|
||||
const wrapper = shallowMount(DataTable, {
|
||||
props: {
|
||||
data: [],
|
||||
columnSettingsMode: 'hide',
|
||||
columns: [
|
||||
{ key: 'actions', label: '操作', fixed: 'left', slotName: 'actions' },
|
||||
{ key: 'customerName', label: '客户' },
|
||||
{ key: 'remark', label: '备注', singleLine: false },
|
||||
],
|
||||
},
|
||||
global: {
|
||||
stubs: { ElTable: TableStub, ElTableColumn: ColumnStub, ElButton: ButtonStub, ElPopover: PopoverStub, ElSelect: true, ElOption: true },
|
||||
directives: { loading: {} },
|
||||
},
|
||||
})
|
||||
|
||||
const columns = wrapper.findAll('.column-stub')
|
||||
expect(columns[0].attributes()).toMatchObject({
|
||||
'data-overflow-tooltip': 'undefined',
|
||||
'data-class-name': 'data-table__system-cell',
|
||||
})
|
||||
expect(columns[1].attributes()).toMatchObject({
|
||||
'data-overflow-tooltip': 'true',
|
||||
'data-class-name': 'data-table__single-line-cell',
|
||||
})
|
||||
expect(columns[2].attributes('data-overflow-tooltip')).toBe('undefined')
|
||||
expect(columns[2].attributes('data-class-name')).toBe('')
|
||||
})
|
||||
|
||||
it('uses key as the data property for ordinary columns only', () => {
|
||||
const wrapper = shallowMount(DataTable, {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user