mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
parent
d54dfdfac2
commit
b3f31216df
@ -222,13 +222,19 @@ export default class FormItem extends React.Component<FormItemProps, any> {
|
||||
|
||||
// Resolve duplicated ids bug between different forms
|
||||
// https://github.com/ant-design/ant-design/issues/7351
|
||||
onLabelClick = () => {
|
||||
onLabelClick = (e: any) => {
|
||||
const { label } = this.props;
|
||||
const id = this.props.id || this.getId();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const controls = document.querySelectorAll(`[id="${id}"]`);
|
||||
if (controls.length !== 1) {
|
||||
// Only prevent in default situation
|
||||
// Avoid preventing event in `label={<a href="xx">link</a>}``
|
||||
if (typeof label === 'string') {
|
||||
e.preventDefault();
|
||||
}
|
||||
const control = ReactDOM.findDOMNode(this).querySelector(`[id="${id}"]`) as HTMLElement;
|
||||
if (control && control.focus) {
|
||||
control.focus();
|
||||
|
Loading…
Reference in New Issue
Block a user