Skip to content

Commit

Permalink
fix(link): root tag will be replaced span when disabled or loading (#…
Browse files Browse the repository at this point in the history
…1855)

Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin authored Feb 22, 2022
1 parent 147617a commit 5b79a8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Link = React.forwardRef((props, ref) => {

const disabled = disabledProp || loading;

const Component: React.ElementType = component;
const Component: React.ElementType = component === 'a' && disabled ? 'span' : component;
return (
<Component
className={classes}
Expand Down
11 changes: 8 additions & 3 deletions src/link/demos/Link.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Template: Story<LinkProps> = (args) => (
</tr>
<tr>
<td>Disabled</td>
<td>disabled状态的样式</td>
<td>disabled 状态的样式,如果 `disabled=true`,根标签会替换成 `span`</td>
<td>
<Link disabled prefix={<PlusOutlined />} {...args}>
GrowingIO
Expand All @@ -59,7 +59,7 @@ const Template: Story<LinkProps> = (args) => (
</tr>
<tr>
<td>Loading</td>
<td>Loading状态的样式</td>
<td>Loading 状态的样式,如果 `loading=true`,根标签会替换成 `span`</td>
<td>
<Link loading prefix={<PlusOutlined />} {...args}>
GrowingIO
Expand All @@ -79,7 +79,12 @@ Demo.args = {
margin: '4px 8px',
},
};
const LinkTemplate: Story<LinkProps> = (args) => <Link {...args}>GrowingIO</Link>;
const LinkTemplate: Story<LinkProps> = (args) => (
<>
<h4>如果 `disabled` 或 `loading` 为 `true`,则根标签会替换成 `span` 标签</h4>
<Link {...args}>GrowingIO</Link>
</>
);

export const Default = LinkTemplate.bind({});
Default.args = {
Expand Down
1 change: 1 addition & 0 deletions src/link/demos/LinkPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function LinkPage() {
</p>
<p>Upgrading Guide</p>
<ul>
<li>如果 `disabled` 或 `loading` 为 `true`,则根标签会替换成 `span` 标签</li>
<li>Api变化: 参数icon 更改为 参数 prefix</li>
<li>样式变化:颜色变化</li>
<li> 支持原生a标签</li>
Expand Down

1 comment on commit 5b79a8b

@vercel
Copy link

@vercel vercel bot commented on 5b79a8b Feb 22, 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.