GithubHelp home page GithubHelp logo

[BUG] Tabs组件启用折叠,新增或者删除tab后如果右侧仍留有空间,右侧按钮会先active再disabled,看起来就像闪了一下 about semi-design HOT 2 OPEN

yupaits avatar yupaits commented on June 2, 2024
[BUG] Tabs组件启用折叠,新增或者删除tab后如果右侧仍留有空间,右侧按钮会先active再disabled,看起来就像闪了一下

from semi-design.

Comments (2)

YyumeiZhang avatar YyumeiZhang commented on June 2, 2024

复现demo

export const Test111 = () => {
  const [num, setNum] = useState(6);
  const [tabList, setTabList] = useState([
    { tab: '文档', itemKey: '1', text: '文档', closable: true },
    { tab: '快速起步', itemKey: '2', text: '快速起步', closable: true },
    { tab: '帮助', itemKey: '3', text: '帮助',closable: true },
    { tab: '文档1', itemKey: '4', text: '文档4', closable: true },
  ]);

  const close = useCallback((key) => [
    setTabList((tabList => {
      return tabList.filter(t=>t.itemKey!==key)
    }))
  ], []);

  const add = useCallback(() => {
    setNum((num) => num+1);
    setTabList((tabList => {
      return [...tabList,
        {
          tab: `文档${num +1}`,
          itemKey: `${num +1}`,
          text: `文档${num +1}`,
          closable: true,
        }
      ]
    }))
  }, [num])

  return (
    <>
      <Button onClick={add}>新增</Button>
      <Tabs type="card" defaultActiveKey="1" onTabClose={close} collapsible style={{ width: 400 }}>
        {
            tabList.map(t=><TabPane closable={t.closable} tab={t.tab} itemKey={t.itemKey} key={t.itemKey}>{t.text}</TabPane>)
        }
      </Tabs>
    </>
);
}

from semi-design.

YyumeiZhang avatar YyumeiZhang commented on June 2, 2024

@YannLynn 有空 cc

from semi-design.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.