Skip to content

Commit

Permalink
fix(comp:table): the fixed column not work with ellipsis (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm committed Aug 22, 2022
1 parent faf0737 commit 423d4cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/cdk/forms/__tests__/formControl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ describe('formControl.ts', () => {

control = new FormControl('test', { validators: Validators.required, asyncValidators: _asyncValidator })

await flushPromises()

expect(control.hasError('required')).toEqual(false)
expect(control.hasError('async')).toEqual(false)

Expand Down
16 changes: 12 additions & 4 deletions packages/components/table/src/main/body/BodyCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@ export default defineComponent({
const activeSortOrderBy = computed(() => activeOrderByMap[props.column.key])
const dataValue = useDataValue(props)

const isFixStartLast = computed(() => fixedColumnKeys.value.lastStartKey === props.column.key)
const isFixEndFirst = computed(() => fixedColumnKeys.value.firstEndKey === props.column.key)

const classes = computed(() => {
const { key, fixed, align, ellipsis = tableProps.ellipsis } = props.column as BodyColumn
const { fixed, align, ellipsis = tableProps.ellipsis } = props.column as BodyColumn
const prefixCls = mergedPrefixCls.value
let classes = {
[`${prefixCls}-sorted`]: !!activeSortOrderBy.value,
[`${prefixCls}-align-${align}`]: !!align,
[`${prefixCls}-ellipsis`]: !!ellipsis,
}
if (fixed) {
const { lastStartKey, firstEndKey } = fixedColumnKeys.value
classes = {
...classes,
[`${prefixCls}-fix-start`]: fixed === 'start',
[`${prefixCls}-fix-start-last`]: lastStartKey === key,
[`${prefixCls}-fix-start-last`]: isFixStartLast.value,
[`${prefixCls}-fix-end`]: fixed === 'end',
[`${prefixCls}-fix-end-first`]: firstEndKey === key,
[`${prefixCls}-fix-end-first`]: isFixEndFirst.value,
[`${prefixCls}-fix-sticky`]: isSticky.value,
}
}
Expand Down Expand Up @@ -102,6 +104,12 @@ export default defineComponent({
title = getColTitle(ellipsis, children, text)
}

// see: https://github.com/IDuxFE/idux/issues/1081
const { fixed, ellipsis = tableProps.ellipsis } = props.column as BodyColumn
if (fixed && ellipsis && (isFixStartLast.value || isFixEndFirst.value)) {
children = <span class={`${mergedPrefixCls.value}-cell-content`}>{children}</span>
}

const customAdditionalFn = tableProps.customAdditional?.bodyCell
const customAdditional = customAdditionalFn
? customAdditionalFn({ column, record: props.record, rowIndex: props.rowIndex })
Expand Down
5 changes: 5 additions & 0 deletions packages/components/table/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
.@{table-prefix}-cell-title {
.ellipsis();
}

.@{table-prefix}-cell-content {
display: block;
.ellipsis();
}
}

&-cell-title {
Expand Down

0 comments on commit 423d4cb

Please sign in to comment.