|
|
@ -302,16 +302,18 @@ export default class FormItem extends React.Component<FormItemProps, any> { |
|
|
|
if (!id) { |
|
|
|
return; |
|
|
|
} |
|
|
|
const controls = document.querySelectorAll(`[id="${id}"]`); |
|
|
|
if (controls.length !== 1) { |
|
|
|
|
|
|
|
const formItemNode = ReactDOM.findDOMNode(this) as Element; |
|
|
|
const control = formItemNode.querySelector(`[id="${id}"]`) as HTMLElement; |
|
|
|
|
|
|
|
if (control) { |
|
|
|
// Only prevent in default situation
|
|
|
|
// Avoid preventing event in `label={<a href="xx">link</a>}``
|
|
|
|
if (typeof label === 'string') { |
|
|
|
e.preventDefault(); |
|
|
|
} |
|
|
|
const formItemNode = ReactDOM.findDOMNode(this) as Element; |
|
|
|
const control = formItemNode.querySelector(`[id="${id}"]`) as HTMLElement; |
|
|
|
if (control && control.focus) { |
|
|
|
|
|
|
|
if (control.focus) { |
|
|
|
control.focus(); |
|
|
|
} |
|
|
|
} |
|
|
|