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

bug: Tabs组件的renderPane失效 #870

Closed
YuanWangZai opened this issue Nov 21, 2023 · 4 comments
Closed

bug: Tabs组件的renderPane失效 #870

YuanWangZai opened this issue Nov 21, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@YuanWangZai
Copy link

Describe the bug

Tabs组件的renderPane失效

以下是我的代码

const ConsTabItems: ITabProps[] = [
        {
            id: 'info',
            name: localize('', '信息'),
            closable: false,
            renderPane: ()=>{
                return <div>test</div>
            },
            status: 'edited'
        },
        {
            id: 'bind',
            name: localize('', '绑定'),
            closable: false,
            renderPane: ()=>{
                return <div>test</div>
            },
        }
    ]

但是点击对应切换后并没有完成页面渲染

Versions

  • OS: win11
  • Browser: chrome
  • Molecule: 1.3.0

To reproduce

Expected

Actually happening

@YuanWangZai YuanWangZai added the bug Something isn't working label Nov 21, 2023
@mortalYoung
Copy link
Collaborator

可以提供更多的信息么 目前的信息看不出问题在哪里

@YuanWangZai
Copy link
Author

这是完整的代码:

const BusInfo = (props: any) => {
    const {
        bus
    } = props

    const ConsTabItems: ITabProps[] = [
        {
            id: 'businfo_info',
            name: localize('', '信息'),
            closable: false,
            renderPane: ()=>{
                return <div>test</div>
            },
        },
        {
            id: 'businfo_bind',
            name: localize('', '绑定'),
            closable: false,
            renderPane: ()=>{
                return <div>test</div>
            },
        }
    ]

    const [tabItems, setTabItems] = useState(ConsTabItems)
    const [activeTab, setActiveTab] = useState('businfo_info')

    useEffect(() => {
    }, [])

    const handleSelTab = (id: any) => {
        setActiveTab(id)

    }
    return (
        <div >
            <div className={'bus-header'}>
                <span>{bus?.name}</span>
            </div>
            <div style={{ height: 300 }}>
                <Tabs
                    activeTab={activeTab}
                    data={tabItems}
                    onSelectTab={handleSelTab}
                    type={'card'} />
            </div>
        </div>
    )
}

export default BusInfo

我希望点击对应的Tab的时候在下方渲染出renderPane的内容,但是并没有,请问应该如何修改代码。另外有没有什么方法可以修改每个Tab显示文字的宽度,谢谢。
image

@mortalYoung
Copy link
Collaborator

Molecule 这边的 Tabs 组件只负责渲染 Tabs 的 Header 内容。内容需要自行调用 renderPane 去渲染。至于 Tabs 的类型上会有 renderPane 的原因是因为 Molecule 里面复用了这个类型,这是一件可以优化点。事实上 Tabs 组件并没有用 renderPane。

可以参考 Panel 组件的源码实现:

https://github.com/DTStack/molecule/blob/57804b644880336cdcb6587d4f7517503ded9f62/src/workbench/panel/panel.tsx

另外有没有什么方法可以修改每个Tab显示文字的宽度

可以直接修改文案的 padding 值,比如:

.mo-panel__header .mo-tab__item{
    padding: 0 20px;
}

@YuanWangZai
Copy link
Author

明白了,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants