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(tabs): remove width='inherit' and height='inherit' #1839

Merged
merged 1 commit into from
Feb 11, 2022
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
5 changes: 3 additions & 2 deletions src/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export const Tabs = WithRef<

const tabPanels = elementList.map((tab: React.ReactElement<WithCommonProps<TabProps>>, index) => {
if (isNil(tab.props.value)) {
return React.cloneElement(<Tab />, { ...tab.props, value: index });
// eslint-disable-next-line react/no-array-index-key
return React.cloneElement(<Tab />, { ...tab.props, value: index, key: index });
}
return React.cloneElement(<Tab />, tab.props);
return React.cloneElement(<Tab />, { ...tab.props, key: tab.props.value });
});

return (
Expand Down
27 changes: 14 additions & 13 deletions src/tabs/demos/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ const templateIconArr = [
<FlowOutlined />,
];
const renderItems = () =>
templateIconArr.map((item, index) => <Tab label={`Option${index}`} value={index} prefix={item} />);
const noTabItem = () => templateIconArr.map((item, index) => <Tab value={index} prefix={item} />);
const noPrefixItems = () => templateIconArr.map((item, index) => <Tab label={`Option${index}`} value={index} />);
templateIconArr.map((item, index) => <Tab label={`Option${index}`} value={index} prefix={item} key={index} />);
const noTabItem = () => templateIconArr.map((item, index) => <Tab value={index} prefix={item} key={index} />);
const noPrefixItems = () =>
templateIconArr.map((item, index) => <Tab label={`Option${index}`} value={index} key={index} />);
const disabledItems = () =>
templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index} disabled={!Math.round(Math.random())} />
<Tab label={`Option${index}`} value={index} disabled={!Math.round(Math.random())} key={index} />
));
const haveChildrenItems = () =>
templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index}>
<Tab label={`Option${index}`} value={index} key={index}>
<div
style={{
backgroundColor: '#f7f8fc',
Expand Down Expand Up @@ -107,12 +108,12 @@ const DemoTemplate: Story<TabsProps> = (args) => (
<td>
<Tabs style={{ marginBottom: 10 }} {...args}>
{templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index} />
<Tab label={`Option${index}`} value={index} key={index} />
))}
</Tabs>
<Tabs size="small" {...args}>
{templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index} />
<Tab label={`Option${index}`} value={index} key={index} />
))}
</Tabs>
</td>
Expand All @@ -123,7 +124,7 @@ const DemoTemplate: Story<TabsProps> = (args) => (
<td style={{ width: 500 }}>
<Tabs {...args}>
{[...Array(10)].map((item, index) => (
<Tab label={`Option${index}`} value={index} />
<Tab label={`Option${index}`} value={index} key={index} />
))}
</Tabs>
</td>
Expand All @@ -141,7 +142,7 @@ const DemoTemplate: Story<TabsProps> = (args) => (
<td>
<Tabs {...args}>
{templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index} prefix={item} />
<Tab label={`Option${index}`} value={index} key={index} prefix={item} />
))}
</Tabs>
</td>
Expand All @@ -152,7 +153,7 @@ const DemoTemplate: Story<TabsProps> = (args) => (
<td>
<Tabs {...args}>
{templateIconArr.map((item, index) => (
<Tab value={index} prefix={item} />
<Tab value={index} prefix={item} key={index} />
))}
</Tabs>
</td>
Expand All @@ -163,7 +164,7 @@ const DemoTemplate: Story<TabsProps> = (args) => (
<td>
<Tabs {...args}>
{templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index} />
<Tab label={`Option${index}`} value={index} key={index} />
))}
</Tabs>
</td>
Expand All @@ -174,7 +175,7 @@ const DemoTemplate: Story<TabsProps> = (args) => (
<td>
<Tabs {...args}>
{templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index} disabled={!Math.round(Math.random())} />
<Tab label={`Option${index}`} value={index} key={index} disabled={!Math.round(Math.random())} />
))}
</Tabs>
</td>
Expand All @@ -190,7 +191,7 @@ const DemoTemplate: Story<TabsProps> = (args) => (
}}
>
{templateIconArr.map((item, index) => (
<Tab label={`Option${index}`} value={index}>
<Tab label={`Option${index}`} value={index} key={index}>
<div
style={{
backgroundColor: '#f7f8fc',
Expand Down
4 changes: 1 addition & 3 deletions src/tabs/style/index.less
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
@import '../../stylesheet/variables/index.less';
@import (reference) '../../stylesheet/variables/index.less';

@tabs-prefix-cls: ~'@{component-prefix}-tabs';

.@{tabs-prefix-cls} {
display: block;
width: inherit;
height: inherit;
overflow-y: auto;
.scrollbar(@x: overlay, @y: overlay);

Expand Down