gender step gets custom input ref, focuses on click

This commit is contained in:
Ben Wheeler 2019-08-13 17:43:28 -04:00
parent 5ec8811427
commit 2aa5ea0f02

View file

@ -55,9 +55,13 @@ class GenderStep extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
bindAll(this, [ bindAll(this, [
'handleSetCustomRef',
'handleValidSubmit' 'handleValidSubmit'
]); ]);
} }
handleSetCustomRef (customInputRef) {
this.customInput = customInputRef;
}
handleValidSubmit (formData, formikBag) { handleValidSubmit (formData, formikBag) {
formikBag.setSubmitting(false); formikBag.setSubmitting(false);
if (!formData.gender || formData.gender === 'null') { if (!formData.gender || formData.gender === 'null') {
@ -122,7 +126,10 @@ class GenderStep extends React.Component {
{'gender-radio-row-selected': (values.gender === values.custom)} {'gender-radio-row-selected': (values.gender === values.custom)}
)} )}
/* eslint-disable react/jsx-no-bind */ /* eslint-disable react/jsx-no-bind */
onClick={() => setFieldValue('gender', values.custom, false)} onClick={() => {
setFieldValue('gender', values.custom, false);
if (this.customInput) this.customInput.focus();
}}
/* eslint-enable react/jsx-no-bind */ /* eslint-enable react/jsx-no-bind */
> >
<FormikRadioButton <FormikRadioButton
@ -139,6 +146,7 @@ class GenderStep extends React.Component {
gender: newCustomVal, gender: newCustomVal,
custom: newCustomVal custom: newCustomVal
})} })}
onSetCustomRef={this.handleSetCustomRef}
/* eslint-enable react/jsx-no-bind */ /* eslint-enable react/jsx-no-bind */
/> />
</div> </div>