Tag should be span than a div semantically

close #17963
This commit is contained in:
afc163 2019-07-30 11:46:10 +08:00
parent 4a3cf8d6e7
commit f15c08a898
2 changed files with 11 additions and 7 deletions

View File

@ -29,7 +29,7 @@ export default class CheckableTag extends React.Component<CheckableTagProps> {
);
delete (restProps as any).onChange; // TypeScript cannot check delete now.
return <div {...(restProps as any)} className={cls} onClick={this.handleClick} />;
return <span {...(restProps as any)} className={cls} onClick={this.handleClick} />;
};
render() {

View File

@ -11,7 +11,7 @@ import Wave from '../_util/wave';
export { CheckableTagProps } from './CheckableTag';
export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
prefixCls?: string;
className?: string;
color?: string;
@ -118,19 +118,23 @@ class Tag extends React.Component<TagProps, TagState> {
const { prefixCls: customizePrefixCls, children, ...otherProps } = this.props;
const isNeedWave =
'onClick' in otherProps || (children && (children as React.ReactElement<any>).type === 'a');
const divProps = omit(otherProps, ['onClose', 'afterClose', 'color', 'visible', 'closable']);
const tagProps = omit(otherProps, ['onClose', 'afterClose', 'color', 'visible', 'closable']);
return isNeedWave ? (
<Wave>
<div {...divProps} className={this.getTagClassName(configProps)} style={this.getTagStyle()}>
<span
{...tagProps}
className={this.getTagClassName(configProps)}
style={this.getTagStyle()}
>
{children}
{this.renderCloseIcon()}
</div>
</span>
</Wave>
) : (
<div {...divProps} className={this.getTagClassName(configProps)} style={this.getTagStyle()}>
<span {...tagProps} className={this.getTagClassName(configProps)} style={this.getTagStyle()}>
{children}
{this.renderCloseIcon()}
</div>
</span>
);
};