mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
🐛 Fix non-boolean attribute
and unique key
warning
close #19303 close #19354
This commit is contained in:
parent
6236537d1d
commit
b882b8dd2f
@ -68,7 +68,7 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
return <Icon className={`${prefixCls}-icon`} type="loading" />;
|
||||
return <Icon className={`${prefixCls}-icon`} type="loading" key="loadingIcon" />;
|
||||
};
|
||||
|
||||
renderSuffix = (prefixCls: string) => {
|
||||
@ -80,7 +80,7 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
|
||||
if (enterButton) return suffix;
|
||||
|
||||
const node = (
|
||||
const icon = (
|
||||
<Icon
|
||||
className={`${prefixCls}-icon`}
|
||||
type="search"
|
||||
@ -90,16 +90,17 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
);
|
||||
|
||||
if (suffix) {
|
||||
let cloneSuffix = suffix;
|
||||
if (React.isValidElement(cloneSuffix) && !cloneSuffix.key) {
|
||||
cloneSuffix = React.cloneElement(cloneSuffix, {
|
||||
key: 'originSuffix',
|
||||
});
|
||||
}
|
||||
return [cloneSuffix, node];
|
||||
return [
|
||||
React.isValidElement(suffix)
|
||||
? React.cloneElement(suffix, {
|
||||
key: 'suffix',
|
||||
})
|
||||
: null,
|
||||
icon,
|
||||
];
|
||||
}
|
||||
|
||||
return node;
|
||||
return icon;
|
||||
};
|
||||
|
||||
renderAddonAfter = (prefixCls: string) => {
|
||||
@ -144,7 +145,14 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
}
|
||||
|
||||
if (addonAfter) {
|
||||
return [button, addonAfter];
|
||||
return [
|
||||
button,
|
||||
React.isValidElement(addonAfter)
|
||||
? React.cloneElement(addonAfter, {
|
||||
key: 'addonAfter',
|
||||
})
|
||||
: null,
|
||||
];
|
||||
}
|
||||
|
||||
return button;
|
||||
@ -161,6 +169,7 @@ export default class Search extends React.Component<SearchProps, any> {
|
||||
} = this.props;
|
||||
|
||||
delete (restProps as any).onSearch;
|
||||
delete (restProps as any).loading;
|
||||
|
||||
const prefixCls = getPrefixCls('input-search', customizePrefixCls);
|
||||
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
|
||||
|
@ -69,7 +69,7 @@ ReactDOM.render(
|
||||
<Input.TextArea rows={1} style={{ width: 100 }} />
|
||||
<Button type="primary">Button</Button>
|
||||
<Input style={{ width: 100 }} />
|
||||
<Text copiable>Ant Design</Text>
|
||||
<Text copyable>Ant Design</Text>
|
||||
<Input prefix="1" suffix="2" style={{ width: 100 }} />
|
||||
<Input addonBefore="1" addonAfter="2" style={{ width: 100 }} />
|
||||
<InputNumber style={{ width: 100 }} />
|
||||
|
@ -23,7 +23,7 @@ ReactDOM.render(
|
||||
<Search placeholder="input search loading deault" loading />
|
||||
<br />
|
||||
<br />
|
||||
<Search placeholder="input search loading with suffix" loading suffix="suffix" />
|
||||
<Search placeholder="input search loading with suffix" loading />
|
||||
<br />
|
||||
<br />
|
||||
<Search placeholder="input search loading with enterButton" loading enterButton />
|
||||
@ -33,7 +33,6 @@ ReactDOM.render(
|
||||
placeholder="input search loading with enterButton and addonAfter"
|
||||
loading
|
||||
enterButton
|
||||
addonAfter="addonAfter"
|
||||
/>
|
||||
</div>,
|
||||
mountNode,
|
||||
|
Loading…
Reference in New Issue
Block a user