setValue() clears text input incorrectly when caret gets to the beginning of the input on focus