question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to disable default blur handler

See original GitHub issue

Summary 💡

Not all use cases may wish to have the Formik onBlur function called to touch fields when blurring. Ideally there would be a way to disable this behaviour (see motiviation section). I do not know whether it would be possible for users to disable this globally, or whether it might just need to respect the Formik validateOnBlur maybe, or another option all together?

Obviously this can be disabled “manually” by passing a custom no-op onBlur function; however, this would require passing a no-op to every textfield (or general MUI form component) or wrapping in a custom component (not awful, but not ideal).

Motivation 🔦

While common, calling the blur function automatically results in fields being “touched” on blur, while some people may wish to only have them touched on submit. For example, it may be desired to not see errors until after the initial submit, which is not possible currently (as fields are touched on blur).

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
cliedemancommented, Apr 29, 2022

I actually use a mixture of both. I have several projects using it and some of the more complicated components (Autocomplete) is really tricky to do right. But yes the core goal is to get people going quickly

1reaction
cliedemancommented, Apr 29, 2022

I have managed to avoid this so far but I thought we might eventually need it.

We could create a Context that allows users to customize beaviour

interface FormikMuiContextType {
  disableSubmitLoading: boolean,
  disableDefaultBlurHandler: boolean,
}

const FormikMuiContext = React.createContext({
  // defaults
  disableSubmitLoading: false,
  disableDefaultBlurHandler: false,
})

Then users can customize behaviour globaly or per form or component

(Select is probably an oversight)

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to disable blur temporary? - jquery - Stack Overflow
1 Answer 1 ... Put a global flag in your blur handler and you can then set or unset that flag to determine...
Read more >
No blur event fired when button is disabled/removed #9142
When a focussed button becomes disabled, React does not dispatch a blur event. ... while this React component doesn't fire the blur handler....
Read more >
How many of you disable the motion blur in your user.cfg?
Motion Blur and DoF are both disabled by default for all games I play. Can't stand it, gives me headaches if it's active....
Read more >
Element: blur event - Web APIs | MDN
The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does...
Read more >
Window blurs | Android Open Source Project
Open the UI that has blur. · Enable or disable window blurs by turning window blur on and off. · Verify that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found