Cursor resets when text is cleared