Skip to content

Commit

Permalink
fix: tagRender should not be called when value is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jan 12, 2025
1 parent fa18f57 commit 22a6831
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Selector/MultipleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ const SelectSelector: React.FC<SelectorProps> = (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)
Expand Down
14 changes: 14 additions & 0 deletions tests/Tags.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Select
mode="tags"
value={[]}
tagRender={tagRender}
options={[{ value: 'light' }, { value: 'dark' }]}
/>,
);
expect(tagRender).not.toHaveBeenCalled();
});

it('disabled', () => {
const tagRender = jest.fn();
render(
Expand Down

0 comments on commit 22a6831

Please sign in to comment.