ReactJS 및 Material UI를 사용하여 응용 프로그램을 만들고 있습니다. FormControl 구성 요소 안에 Input 구성 요소가 있습니다. 사용자가 FormControl을 클릭했을 때 (그러나 여전히 Input 컴포넌트 외부에있을 때) Input 컴포넌트에 초점을 맞추고 싶습니다. 어떻게이 일을 성취 할 수 있습니까? 나는 심판과 시도했지만 나는 그것을 할 수 없습니다 :해당 영역 외부를 클릭하면 MUI 입력 구성 요소에 포커스가 설정됩니다.
<FormControl
onClick={this.textInput.focus()}
style={{ display: 'block', cursor: 'text' }}
>
<Input
error={this.props.error}
disabled={this.props.disabled}
ref={(input) => { this.textInput = input; }}
/>
</FormControl>
감사를 사전에 도움
을 :
이 코드는 작동합니다 (https://material-ui-next.com/customization/api/#internal-components 참조) 정의되지 않은 재산 '초점'을 읽을 수 없습니다 – Anto