Re-focus input after `clear()`
See original GitHub issueI am using the clear()
method to implement input box clearing on mobile devices, i.e. when tapping on a small “x” in a circle. It kinda works, but the fact that clear()
will automatically also blur the input field feels a bit weird. I have to focus()
it immediately, and this causes flickering. Thus, it would be better if clear()
had an option to prevent blurring.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Set focus back to input after resetting form - Stack Overflow
I have a form that has an input field that has autofocus with a reset button. When resetting the form, I would like...
Read more >How To Clear Input Field on Focus - W3Schools
Learn how to clear an input field on focus. Click on the input field to clear it: Clear Input Field on Focus. Example....
Read more >ReactBits: Clearable Input with Autofocus | by Luis Guerrero
An input with a clear button inside; The clear button should only be displayed if the input is not empty and it is...
Read more >How to clear an input field on focus with JavaScript
JavaScript has a onfocus() event that occurs when the element gets focused. This onfocus() event can be used to clear the input field....
Read more >Clear Field on Focus - CSS-Tricks
I am trying to tweak the CSS code above to clear my form fields. ... The only script for the mini cart is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works for me with no flickering:
As of v2.4.0, the input retains focus when clicking the clear button. Note that if the button is focused via keystroke (eg: tabbing), the input will blur and won’t automatically regain focus on clear.