From 22a6831d46e1b4d30ba9024beee54bdf68e4633a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 12 Jan 2025 15:22:14 +0800 Subject: [PATCH] fix: tagRender should not be called when value is empty --- src/Selector/MultipleSelector.tsx | 4 ++++ tests/Tags.test.tsx | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Selector/MultipleSelector.tsx b/src/Selector/MultipleSelector.tsx index e6a2643f..751ae1b7 100644 --- a/src/Selector/MultipleSelector.tsx +++ b/src/Selector/MultipleSelector.tsx @@ -188,6 +188,10 @@ const SelectSelector: React.FC = (props) => { }; const renderRest = (omittedValues: DisplayValueType[]) => { + // https://github.com/ant-design/ant-design/issues/48930 + if (!values.length) { + return null; + } const content = typeof maxTagPlaceholder === 'function' ? maxTagPlaceholder(omittedValues) diff --git a/tests/Tags.test.tsx b/tests/Tags.test.tsx index 305380c6..944f486a 100644 --- a/tests/Tags.test.tsx +++ b/tests/Tags.test.tsx @@ -323,6 +323,20 @@ describe('Select.Tags', () => { }); }); + // https://github.com/ant-design/ant-design/issues/48930 + it('should not call tagRender when value is empty', () => { + const tagRender = jest.fn(); + render( +