Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tag-input): tag props should effect collapsed tag #2869

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"@types/tinycolor2": "^1.4.3",
"@types/validator": "^13.1.3",
"classnames": "~2.3.1",
"dayjs": "~1.11.4",
"dayjs": "1.11.10",
"hoist-non-react-statics": "~3.3.2",
"lodash": "~4.17.15",
"mitt": "^3.0.0",
Expand Down
15 changes: 15 additions & 0 deletions src/tag-input/__tests__/vitest-tag-input.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ describe('TagInput Component', () => {
expect(container.querySelector('.custom-node')).toBeTruthy();
});

it('props.tagProps should effect collapsed tag', () => {
const { container } = render(
<TagInput
size="large"
tagProps={{ size: 'small' }}
value={['Vue', 'React', 'Miniprogram', 'Angular', 'Flutter']}
minCollapsedNum={1}
></TagInput>,
);
// normal tag
expect(container.querySelectorAll('.t-tag')[0]).toHaveClass('t-size-s');
// collapsed tag
expect(container.querySelectorAll('.t-tag')[1]).toHaveClass('t-size-s');
});

it('props.tag works fine', () => {
const { container } = getTagInputValueMount(TagInput, {
tag: <span className="custom-node">TNode</span>,
Expand Down
10 changes: 9 additions & 1 deletion src/tag-input/useTagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ export default function useTagList(props: TagInputProps) {
collapsedTags: tagValue.slice(minCollapsedNum, tagValue.length),
};
const more = isFunction(collapsedItems) ? collapsedItems(params) : collapsedItems;
list.push(<Fragment key="more">{more ?? <Tag size={size}>+{len}</Tag>}</Fragment>);
list.push(
<Fragment key="more">
{more ?? (
<Tag size={size} {...tagProps}>
+{len}
</Tag>
)}
</Fragment>,
);
HaixingOoO marked this conversation as resolved.
Show resolved Hide resolved
}
return list;
};
Expand Down
Loading