Is it possible to clear the input programatically
See original GitHub issueI would like to clear the input box programmatically. I’ve almost made it work, but the result is the dropdown opens again ad a side effect.
I’m doing this:
accessibleAutocomplete({
element: containerElement,
selectElement: multiselectElement,
defaultValue: '',
confirmOnBlur: false,
showAllValues: true,
id: autocompleteId,
onConfirm: handleAdd,
source: getSource
});
function handleAdd(value) {
// hack to clear the input box. delay 150ms to allow the react component
// to render iwth the new value first.
// hide the selected value by making it the same colour as the input box
autocompleteInputElement.style.color = 'white';
setTimeout(function() {
autocompleteInputElement.value = '';
autocompleteInputElement.style.color = 'black';
}, 150);
}
yes., it’s a horrible hack and is subject to race condition. is there a built-in way?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Is there a way to programmatically clear an input's value ...
One option is to include a Boolean, called cleared , for example, in your model. If cleared is True, in your view function...
Read more >HTML | Clearing the input field - GeeksforGeeks
To clear the entire input field without having to delete the whole thing manually Or what if there is already a pre-suggested input...
Read more >Clear form input programmatically - Framework7 Forum
I want to simulate the 'input-clear-button' programmatically - F7 uses the function clearInput but when I call that I get an error Cant...
Read more >How to Clear Input Fields in JavaScript - Linux Hint
To clear input fields in JavaScript, use the onfocus event and target property,onclick event and document.getElementById() method or the reset() method.
Read more >How to Clear Input Values of Dynamic Form in React
How to clear the values all inputs. At the top of handleReset , use document.querySelectorAll('input') to select all the input elements on the ......
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
Fixed. The source repo had a reorg, so repointed to the new location.
I got this working fully today (I hope!). Code here.
Required this dance to get it to work:
How it looks on our service: