fix: table ellipsis title not work, close #5755
parent
d94fe1c0b2
commit
f672f873dc
|
@ -1,7 +1,12 @@
|
||||||
import classNames from '../../_util/classNames';
|
import classNames from '../../_util/classNames';
|
||||||
import { flattenChildren, isValidElement, parseStyleText } from '../../_util/props-util';
|
import {
|
||||||
import type { CSSProperties } from 'vue';
|
filterEmpty,
|
||||||
import { computed, defineComponent, isVNode, renderSlot } from 'vue';
|
flattenChildren,
|
||||||
|
isValidElement,
|
||||||
|
parseStyleText,
|
||||||
|
} from '../../_util/props-util';
|
||||||
|
import type { CSSProperties, VNodeArrayChildren } from 'vue';
|
||||||
|
import { Text, computed, defineComponent, isVNode, renderSlot } from 'vue';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
DataIndex,
|
DataIndex,
|
||||||
|
@ -145,6 +150,18 @@ export default defineComponent<CellProps>({
|
||||||
|
|
||||||
additionalProps?.onMouseleave?.(event);
|
additionalProps?.onMouseleave?.(event);
|
||||||
};
|
};
|
||||||
|
const getTitle = (vnodes: VNodeArrayChildren) => {
|
||||||
|
const vnode = filterEmpty(vnodes)[0];
|
||||||
|
if (isVNode(vnode)) {
|
||||||
|
if (vnode.type === Text) {
|
||||||
|
return vnode.children;
|
||||||
|
} else {
|
||||||
|
return Array.isArray(vnode.children) ? getTitle(vnode.children) : undefined;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return vnode;
|
||||||
|
}
|
||||||
|
};
|
||||||
return () => {
|
return () => {
|
||||||
const {
|
const {
|
||||||
prefixCls,
|
prefixCls,
|
||||||
|
@ -298,8 +315,8 @@ export default defineComponent<CellProps>({
|
||||||
if (ellipsisConfig && (ellipsisConfig.showTitle || rowType === 'header')) {
|
if (ellipsisConfig && (ellipsisConfig.showTitle || rowType === 'header')) {
|
||||||
if (typeof childNode === 'string' || typeof childNode === 'number') {
|
if (typeof childNode === 'string' || typeof childNode === 'number') {
|
||||||
title = childNode.toString();
|
title = childNode.toString();
|
||||||
} else if (isVNode(childNode) && typeof childNode.children === 'string') {
|
} else if (isVNode(childNode)) {
|
||||||
title = childNode.children;
|
title = getTitle([childNode]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue