Skip to content

Commit

Permalink
Fix focus/select loop when iOS Safari autofill is triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Nov 30, 2020
1 parent 3add591 commit 3e79746
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/TimeInput/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import updateInputWidth, { getFontShorthand } from 'update-input-width';

/* eslint-disable jsx-a11y/no-autofocus */

const isEdgeLegacy = navigator.userAgent.match(/ Edge\/1/);

function onFocus(event) {
const { target } = event;

requestAnimationFrame(() => target.select());
if (isEdgeLegacy) {
requestAnimationFrame(() => target.select());
} else {
target.select();
}
}

function updateInputWidthOnFontLoad(element) {
Expand Down

0 comments on commit 3e79746

Please sign in to comment.