Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field not touched when using up/down arrow selectors on type='number' Fields #2983

Closed
esr52 opened this issue Dec 28, 2020 · 9 comments
Closed

Comments

@esr52
Copy link

esr52 commented Dec 28, 2020

Bug report

Current Behavior

Using up/down "scoller" arrows with mouse on number type Field, setFieldTouched not set. I'm depending on the touched field to enable an update button. Seems redundant to have to click inside the field after changing the value using the scoller arrows.

image

Expected behavior

When up/down arrow clicked, setFieldTouched should trigger

Reproducible example

<Formik
      initialValues={{
        ...initVals,
      }}
      validationSchema={mylValidationSchema}
      onSubmit={onSubmit}
      enableReinitialize
    >
      {(
        { values, setFieldValue, touched, dirty, isValid, handleBlur } // this is for DatePicker
      ) => (
        <Form styling='structure'>
        ...
                  <div className='block ml-5'>
                        <div className='d-flex'>
                          <div className='input-group'>
                            <Label htmlFor='correctionFactor'>
                              Correction Factor
                            </Label>
                          </div>
                          <Field
                            id='correctionFactor'
                            name='correctionFactor'
                            type='number'
                          />
                        </div>
                        <ErrorMessage
                          name='correctionFactor'
                          component={TextError}
                        />
                      </div>
                      ...
          </Form>)}
    </Formik>

Suggested solution(s)

Additional context

Your environment

Software Version(s)
Formik 2.2.6
React 16.13.1
TypeScript
Browser Firefox
npm/Yarn npm
Operating System MX Linux 19.3
@mkarajohn
Copy link

Not sure if this is an acceptable solution, but you could manually set it to touched by calling setFieldTouched when the value changes ( I suppose the onChange event does fire when you change the number with the buttons)

@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 60 days

@github-actions github-actions bot added the stale label Jan 30, 2021
@mkarajohn
Copy link

Commenting to remove the stale label

@github-actions github-actions bot removed the stale label Jan 31, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 60 days

@github-actions github-actions bot added the stale label Mar 3, 2021
@johnrom
Copy link
Collaborator

johnrom commented Mar 3, 2021

This is not what touched means. Touched occurs when a user left / blurred a field. It is a way for Formik to say "a user is done with this field and may want to know if there were any errors".

Are you saying that using the keyboard to update the value and then navigating away from the selectors doesn't result in touched?

@esr52
Copy link
Author

esr52 commented Mar 3, 2021 via email

@johnrom
Copy link
Collaborator

johnrom commented Mar 3, 2021

hmm.. interesting. Seems like a browser bug in Firefox to me, I would expect blur to happen as I described above.

Edit: it is a Firefox bug

@johnrom
Copy link
Collaborator

johnrom commented Mar 3, 2021

Some discussion here on workarounds: facebook/react#11062

I wouldn't probably implement anything like this in Formik itself. Any workarounds can be discussed here, though.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 60 days

@github-actions github-actions bot added the stale label Apr 3, 2021
@github-actions github-actions bot closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants