Skip to content

Commit 0808cdc

Browse files
committed
Fix inputs not always being measured after document load on Safari
1 parent 4de8245 commit 0808cdc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/DateInput/Input.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ function onFocus(event) {
2222
}
2323
}
2424

25+
function updateInputWidthOnLoad(element) {
26+
if (document.readyState === 'complete') {
27+
return;
28+
}
29+
30+
function onLoad() {
31+
updateInputWidth(element);
32+
}
33+
34+
window.addEventListener('load', onLoad);
35+
}
36+
2537
function updateInputWidthOnFontLoad(element) {
2638
if (!document.fonts) {
2739
return;
@@ -110,6 +122,7 @@ export default function Input({
110122
}
111123

112124
updateInputWidth(inputRef.current);
125+
updateInputWidthOnLoad(inputRef.current);
113126
updateInputWidthOnFontLoad(inputRef.current);
114127
}, [inputRef, value]);
115128

0 commit comments

Comments
 (0)