diff --git a/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts b/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts index 0b8ad1427e0c..9dd3d684e0d6 100644 --- a/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts +++ b/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts @@ -162,6 +162,18 @@ export const useFieldV6TextField: UseFieldTextField = (params) => { inputRef.current.setSelectionRange(selectionStart, selectionEnd); } } + setTimeout(() => { + // handle case when the selection is not updated correctly + // could happen on Android + if ( + inputRef.current && + inputRef.current === getActiveElement(document) && + (inputRef.current.selectionStart !== selectionStart || + inputRef.current.selectionEnd !== selectionEnd) + ) { + interactions.syncSelectionToDOM(); + } + }); } // Even reading this variable seems to do the trick, but also setting it just to make use of it