DouyinFE / semi-design

🚀A modern, comprehensive, flexible design system and React UI library. 🎨 Provide more than 3000+ Design Tokens, easy to build your design system. Make Semi Design to Any Design. 🧑🏻‍💻 Design to Code in one click
https://semi.design
Other
8.3k stars 700 forks source link

[Tag] <TagGroup closable 关闭后省略数量指示器仍然不变> #945

Closed DaiQiangReal closed 2 years ago

DaiQiangReal commented 2 years ago

Is there an existing issue for this?

Which Component

tag

Semi Version

latest

Current Behavior

No response

Expected Behavior

No response

Steps To Reproduce

点击第一个tag 的 x 关闭tag后,还是 +2

ReproducibleCode

import React from 'react';
import { TagGroup } from '@douyinfe/semi-ui';

() => {
    const tagList = [
        { color: 'white', children:'抖音'},
        { color: 'white', children:'火山小视频'},
        { color: 'white', children:'剪映'},
        { color: 'white', children:'皮皮虾'},
    ];
    const src = 'https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg';
    const tagList2 = [
        { color: 'white', children:'Douyin', avatarSrc:src,closable:true},
        { color: 'white', children:'Hotsoon', avatarSrc:src,closable:true},
        { color: 'white', children:'Capcut', avatarSrc:src,closable:true},
        { color: 'white', children:'Pipixia', avatarSrc:src,closable:true},
    ];
    const divStyle = {
        backgroundColor: 'var(--semi-color-fill-0)',
        height: 35,
        width: 300,
        display: 'flex',
        alignItems: 'center',
        padding: '0 10px',
        marginBottom: 30,
    };
    const tagGroupStyle = {
        display: 'flex',
        alignItems: 'center',
        width: 350,
    };
    return (
        <>

            <div style={divStyle}>
                <TagGroup
                    maxTagCount={2}
                    style={tagGroupStyle}
                    tagList={tagList2}
                    size='large'
                    avatarShape='circle'
                    showPopover
                />
            </div>
        </>
    );
};

Environment

- OS:
- browser:

Anything else?

No response

linjunc commented 2 years ago

我正在解这个 bug,可以 assign 给我

linjunc commented 2 years ago

遇到一些问题希望得到帮助,在处理这个问题的时候发现了一些问题

pointhalo commented 2 years ago

不知道 Tag 有没有类似的能够作为 key 的,我尝试用 children 作为 key ,但是这不是很合理,或许可以考虑加多一个 value / key 字段?或者还有什么办法咩?

image

可以加一个key字段让用户传入,如果不传key,则先判断children类型,如果是string or number降级到用 children (tag的children多为字符串,极少为 reactNode,一般不会有什么问题) 如果children为其他类型,再采用 random key作为兜底

pointhalo commented 2 years ago

v 2.18.0-beta.0 fix,增加 onTagClose 回调,接收回调更新 tagList 以更新数字显示