I am facing an issue with resetting/clearing an input field using a button click:
Take a look at the code here for reference.
const searchInput = useRef(null);
const clearInput = () => {
searchInput.current.value = '';
searchInput.current.blur();
}
return (
<div>
<Input
inputRef={searchInput}
id="outlined-basic"
label="Outlined"
variant="outlined" />
<button onClick={clearInput}>Clear</button>
</div>
);
After clearing the input, the issue is that the label does not reset to its original position. This seems to be happening because the input field still thinks it has focus. I have tried using blur(), but it doesn't seem to resolve the problem.