From d38cdd0e2a052b0474545bce3ded064e3fd0acf8 Mon Sep 17 00:00:00 2001 From: zombiej Date: Fri, 19 Nov 2021 17:53:45 +0800 Subject: [PATCH] fix: maxTagTextLength should not cut label content --- src/Selector/MultipleSelector.tsx | 9 ++++----- tests/__snapshots__/Multiple.test.tsx.snap | 4 ++-- tests/__snapshots__/Tags.test.tsx.snap | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Selector/MultipleSelector.tsx b/src/Selector/MultipleSelector.tsx index 8cc214b1b..bcfa08884 100644 --- a/src/Selector/MultipleSelector.tsx +++ b/src/Selector/MultipleSelector.tsx @@ -92,6 +92,7 @@ const SelectSelector: React.FC = (props) => { // ===================== Render ====================== // >>> Render Selector Node. Includes Item & Rest function defaultRenderSelector( + title: React.ReactNode, content: React.ReactNode, itemDisabled: boolean, closable?: boolean, @@ -103,9 +104,7 @@ const SelectSelector: React.FC = (props) => { [`${selectionPrefixCls}-item-disabled`]: itemDisabled, })} title={ - typeof content === 'string' || typeof content === 'number' - ? content.toString() - : undefined + typeof title === 'string' || typeof title === 'number' ? title.toString() : undefined } > {content} @@ -170,7 +169,7 @@ const SelectSelector: React.FC = (props) => { return typeof tagRender === 'function' ? customizeRenderSelector(value, displayLabel, itemDisabled, closable, onClose) - : defaultRenderSelector(displayLabel, itemDisabled, closable, onClose); + : defaultRenderSelector(label, displayLabel, itemDisabled, closable, onClose); } function renderRest(omittedValues: DisplayLabelValueType[]) { @@ -179,7 +178,7 @@ const SelectSelector: React.FC = (props) => { ? maxTagPlaceholder(omittedValues) : maxTagPlaceholder; - return defaultRenderSelector(content, false); + return defaultRenderSelector(content, content, false); } // >>> Input Node diff --git a/tests/__snapshots__/Multiple.test.tsx.snap b/tests/__snapshots__/Multiple.test.tsx.snap index ffaea00ed..e8b2f4ef4 100644 --- a/tests/__snapshots__/Multiple.test.tsx.snap +++ b/tests/__snapshots__/Multiple.test.tsx.snap @@ -300,7 +300,7 @@ exports[`Select.Multiple render truncates values by maxTagTextLength 1`] = ` >