Browsers seem to make it convenient to replace an <input>'s contents by selecting all text on focusing, but only if you used keyboard navigation. Programmatic focus and clicking on the field do not show this behavior.