Skip to content

Commit 4664a2e

Browse files
authored
fix: tagRender should not be called when value is empty (#1111)
1 parent fd1f076 commit 4664a2e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Selector/MultipleSelector.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
178178
};
179179

180180
const renderRest = (omittedValues: DisplayValueType[]) => {
181+
// https://github.com/ant-design/ant-design/issues/48930
182+
if (!values.length) {
183+
return null;
184+
}
181185
const content =
182186
typeof maxTagPlaceholder === 'function'
183187
? maxTagPlaceholder(omittedValues)

tests/Tags.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,20 @@ describe('Select.Tags', () => {
301301
expectOpen(container, false);
302302
});
303303

304+
// https://github.com/ant-design/ant-design/issues/48930
305+
it('should not call tagRender when value is empty', () => {
306+
const tagRender = jest.fn();
307+
render(
308+
<Select
309+
mode="tags"
310+
value={[]}
311+
tagRender={tagRender}
312+
options={[{ value: 'light' }, { value: 'dark' }]}
313+
/>,
314+
);
315+
expect(tagRender).not.toHaveBeenCalled();
316+
});
317+
304318
it('disabled', () => {
305319
const tagRender = jest.fn();
306320
render(

0 commit comments

Comments
 (0)