Test if input field is in focus before updating it, so it doesn't interrupt the caret position in the field while editing