Preserve selectionStart and selectionEnd on focused input when replacing form