Skip to content

Commit

Permalink
fix(labware-creator): fix radio group touched on change in Mac FF (#4210
Browse files Browse the repository at this point in the history
)

closes #4209
  • Loading branch information
IanLondon authored Oct 14, 2019
1 parent 52cf2cb commit 8c89022
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions labware-library/src/labware-creator/components/RadioField.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ const RadioField = (props: Props) => (
labelTextClassName={props.labelTextClassName}
onChange={e => {
field.onChange(e)
// do not wait until blur to make radio field 'dirty', so that alerts show up immediately.
// NOTE: Ian 2019-10-02 this setTimeout seems necessary to avoid a race condition where
// Formik blurs the field before setting its value, surfacing a transient error
// (eg "this field is required") which messes up error analytics
const blurTarget = e.currentTarget
// do not wait until blur to make radio field 'touched', so that alerts show up immediately.
setTimeout(() => {
blurTarget.blur()
// NOTE: Ian 2019-10-02 this setTimeout seems necessary to avoid a race condition where
// Formik blurs the field before setting its value, surfacing a transient error
// (eg "this field is required") which messes up error analytics.
// See https://github.com/jaredpalmer/formik/issues/1863
//
// NOTE: onBlur doesn't work on Firefox on Mac for radio fields,
// so we can't do `e.currentTarget.blur()`. See https://bugzilla.mozilla.org/show_bug.cgi?id=756028
form.setTouched({ [props.name]: true })
}, 0)

reportFieldEdit({ value: field.value, name: field.name })
Expand Down

0 comments on commit 8c89022

Please sign in to comment.