Skip to content

Commit 395a0ec

Browse files
authored
fix: maxTagTextLength should not cut label content (#675)
1 parent 073edf9 commit 395a0ec

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/Selector/MultipleSelector.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
9292
// ===================== Render ======================
9393
// >>> Render Selector Node. Includes Item & Rest
9494
function defaultRenderSelector(
95+
title: React.ReactNode,
9596
content: React.ReactNode,
9697
itemDisabled: boolean,
9798
closable?: boolean,
@@ -103,9 +104,7 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
103104
[`${selectionPrefixCls}-item-disabled`]: itemDisabled,
104105
})}
105106
title={
106-
typeof content === 'string' || typeof content === 'number'
107-
? content.toString()
108-
: undefined
107+
typeof title === 'string' || typeof title === 'number' ? title.toString() : undefined
109108
}
110109
>
111110
<span className={`${selectionPrefixCls}-item-content`}>{content}</span>
@@ -170,7 +169,7 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
170169

171170
return typeof tagRender === 'function'
172171
? customizeRenderSelector(value, displayLabel, itemDisabled, closable, onClose)
173-
: defaultRenderSelector(displayLabel, itemDisabled, closable, onClose);
172+
: defaultRenderSelector(label, displayLabel, itemDisabled, closable, onClose);
174173
}
175174

176175
function renderRest(omittedValues: DisplayLabelValueType[]) {
@@ -179,7 +178,7 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
179178
? maxTagPlaceholder(omittedValues)
180179
: maxTagPlaceholder;
181180

182-
return defaultRenderSelector(content, false);
181+
return defaultRenderSelector(content, content, false);
183182
}
184183

185184
// >>> Input Node

tests/__snapshots__/Multiple.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ exports[`Select.Multiple render truncates values by maxTagTextLength 1`] = `
300300
>
301301
<span
302302
class="rc-select-selection-item"
303-
title="On..."
303+
title="One"
304304
>
305305
<span
306306
class="rc-select-selection-item-content"
@@ -327,7 +327,7 @@ exports[`Select.Multiple render truncates values by maxTagTextLength 1`] = `
327327
>
328328
<span
329329
class="rc-select-selection-item"
330-
title="Tw..."
330+
title="Two"
331331
>
332332
<span
333333
class="rc-select-selection-item-content"

tests/__snapshots__/Tags.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ exports[`Select.Tags render truncates values by maxTagTextLength 1`] = `
519519
>
520520
<span
521521
class="rc-select-selection-item"
522-
title="On..."
522+
title="One"
523523
>
524524
<span
525525
class="rc-select-selection-item-content"
@@ -546,7 +546,7 @@ exports[`Select.Tags render truncates values by maxTagTextLength 1`] = `
546546
>
547547
<span
548548
class="rc-select-selection-item"
549-
title="Tw..."
549+
title="Two"
550550
>
551551
<span
552552
class="rc-select-selection-item-content"

0 commit comments

Comments
 (0)