Skip to content

Commit 197e209

Browse files
committed
fix: typography #6244
1 parent 82c4c8f commit 197e209

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

components/typography/Base.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type { EventHandler } from '../_util/EventInterface';
3131
import omit from '../_util/omit';
3232
import type { AutoSizeType } from '../input/inputProps';
3333
import useMergedState from '../_util/hooks/useMergedState';
34+
import { findDOMNode } from '../_util/props-util';
3435

3536
export type BaseType = 'secondary' | 'success' | 'warning' | 'danger';
3637

@@ -198,7 +199,9 @@ const Base = defineComponent({
198199
});
199200

200201
function getChildrenText(): string {
201-
return props.ellipsis || props.editable ? props.content : contentRef.value?.$el?.innerText;
202+
return props.ellipsis || props.editable
203+
? props.content
204+
: findDOMNode(contentRef.value)?.innerText;
202205
}
203206

204207
// =============== Expand ===============
@@ -324,7 +327,7 @@ const Base = defineComponent({
324327
if (
325328
!rows ||
326329
rows < 0 ||
327-
!contentRef.value?.$el ||
330+
!findDOMNode(contentRef.value) ||
328331
state.expanded ||
329332
props.content === undefined
330333
)
@@ -338,7 +341,7 @@ const Base = defineComponent({
338341
text,
339342
ellipsis: ell,
340343
} = measure(
341-
contentRef.value?.$el,
344+
findDOMNode(contentRef.value),
342345
{ rows, suffix },
343346
props.content,
344347
renderOperations(true),

components/typography/Title.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const TITLE_ELE_LIST = tupleNum(1, 2, 3, 4, 5);
88

99
export const titleProps = () => ({
1010
...omit(baseProps(), ['component', 'strong']),
11-
level: Number as PropType<typeof TITLE_ELE_LIST[number]>,
11+
level: Number as PropType<(typeof TITLE_ELE_LIST)[number]>,
1212
});
1313

1414
export type TitleProps = Partial<ExtractPropTypes<ReturnType<typeof titleProps>>>;
1515

1616
const Title: FunctionalComponent<TitleProps> = (props, { slots, attrs }) => {
1717
const { level = 1, ...restProps } = props;
1818
let component: string;
19-
if (TITLE_ELE_LIST.indexOf(level) !== -1) {
19+
if (TITLE_ELE_LIST.includes(level)) {
2020
component = `h${level}`;
2121
} else {
2222
warning(false, 'Typography', 'Title only accept `1 | 2 | 3 | 4 | 5` as `level` value.');

components/typography/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
type: General
44
title: Typography
55
cols: 1
6-
cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
6+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*MLt3R6m9huoAAAAAAAAAAAAADrJ8AQ/original
77
---
88

99
Basic text writing, including headings, body text, lists, and more.

components/typography/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ subtitle: 排版
44
type: 通用
55
title: Typography
66
cols: 1
7-
cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
7+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*MLt3R6m9huoAAAAAAAAAAAAADrJ8AQ/original
88
---
99

1010
文本的基本格式。

0 commit comments

Comments
 (0)