diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 4aadf402cd..bc484c6140 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -24,7 +24,6 @@ export const Calendar = React.memo( const [overlayVisibleState, setOverlayVisibleState] = React.useState(false); const [viewDateState, setViewDateState] = React.useState(null); const [idState, setIdState] = React.useState(props.id); - const isTypingRef = React.useRef(false); const metaData = { props, @@ -148,7 +147,6 @@ export const Calendar = React.memo( const value = parseValueFromString(props.timeOnly ? rawValue.replace('_', '') : rawValue); if (isValidSelection(value)) { - isTypingRef.current = true; updateModel(event, value); updateViewDate(event, value.length ? value[0] : value); } @@ -3074,12 +3072,13 @@ export const Calendar = React.memo( const newDate = props.value; if (previousValue !== newDate) { - if (!isTypingRef.current) { + const isInputFocused = document.activeElement === inputRef.current; + + // Do not update value in input if user types something in it: + if (!isInputFocused) { updateInputfield(newDate); } - isTypingRef.current = false; - // #3516 view date not updated when value set programatically if (!newDate) return;