|
1 | 1 | import classNames from '../../_util/classNames';
|
2 |
| -import { flattenChildren, isValidElement, parseStyleText } from '../../_util/props-util'; |
3 |
| -import type { CSSProperties } from 'vue'; |
4 |
| -import { computed, defineComponent, isVNode, renderSlot } from 'vue'; |
| 2 | +import { |
| 3 | + filterEmpty, |
| 4 | + flattenChildren, |
| 5 | + isValidElement, |
| 6 | + parseStyleText, |
| 7 | +} from '../../_util/props-util'; |
| 8 | +import type { CSSProperties, VNodeArrayChildren } from 'vue'; |
| 9 | +import { Text, computed, defineComponent, isVNode, renderSlot } from 'vue'; |
5 | 10 |
|
6 | 11 | import type {
|
7 | 12 | DataIndex,
|
@@ -145,6 +150,18 @@ export default defineComponent<CellProps>({
|
145 | 150 |
|
146 | 151 | additionalProps?.onMouseleave?.(event);
|
147 | 152 | };
|
| 153 | + const getTitle = (vnodes: VNodeArrayChildren) => { |
| 154 | + const vnode = filterEmpty(vnodes)[0]; |
| 155 | + if (isVNode(vnode)) { |
| 156 | + if (vnode.type === Text) { |
| 157 | + return vnode.children; |
| 158 | + } else { |
| 159 | + return Array.isArray(vnode.children) ? getTitle(vnode.children) : undefined; |
| 160 | + } |
| 161 | + } else { |
| 162 | + return vnode; |
| 163 | + } |
| 164 | + }; |
148 | 165 | return () => {
|
149 | 166 | const {
|
150 | 167 | prefixCls,
|
@@ -298,8 +315,8 @@ export default defineComponent<CellProps>({
|
298 | 315 | if (ellipsisConfig && (ellipsisConfig.showTitle || rowType === 'header')) {
|
299 | 316 | if (typeof childNode === 'string' || typeof childNode === 'number') {
|
300 | 317 | title = childNode.toString();
|
301 |
| - } else if (isVNode(childNode) && typeof childNode.children === 'string') { |
302 |
| - title = childNode.children; |
| 318 | + } else if (isVNode(childNode)) { |
| 319 | + title = getTitle([childNode]); |
303 | 320 | }
|
304 | 321 | }
|
305 | 322 |
|
|
0 commit comments