Skip to content

Commit

Permalink
fix(tabs): remove width='inherit' and height='inherit' (#1839)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Feb 11, 2022
1 parent 40e5162 commit 679be96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
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

1 comment on commit 679be96

@vercel
Copy link

@vercel vercel bot commented on 679be96 Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.