Skip to content

Commit

Permalink
fix: tagRender should not be called when value is empty (#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Jan 12, 2025
1 parent fd1f076 commit 4664a2e
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 @@ -178,6 +178,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 @@ -301,6 +301,20 @@ describe('Select.Tags', () => {
expectOpen(container, false);
});

// 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 4664a2e

Please sign in to comment.