File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
packages/x-date-pickers/src/internals/hooks/useField Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -426,7 +426,7 @@ export const useField = <
426
426
// On multi input range pickers we want to update selection range only for the active input
427
427
// This helps to avoid the focus jumping on Safari https://github.com/mui/mui-x/issues/9003
428
428
// because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425
429
- if ( inputRef . current === getActiveElement ( document ) ) {
429
+ if ( inputRef . current === getActiveElement ( inputRef . current . ownerDocument ) ) {
430
430
inputRef . current . setSelectionRange ( selectionStart , selectionEnd ) ;
431
431
}
432
432
// Even reading this variable seems to do the trick, but also setting it just to make use of it
@@ -459,7 +459,7 @@ export const useField = <
459
459
460
460
React . useEffect ( ( ) => {
461
461
// Select the right section when focused on mount (`autoFocus = true` on the input)
462
- if ( inputRef . current && inputRef . current === document . activeElement ) {
462
+ if ( inputRef . current && inputRef . current === inputRef . current . ownerDocument . activeElement ) {
463
463
setSelectedSections ( 'all' ) ;
464
464
}
465
465
@@ -495,7 +495,8 @@ export const useField = <
495
495
return 'numeric' ;
496
496
} , [ selectedSectionIndexes , state . sections ] ) ;
497
497
498
- const inputHasFocus = inputRef . current && inputRef . current === getActiveElement ( document ) ;
498
+ const inputHasFocus =
499
+ inputRef . current && inputRef . current === getActiveElement ( inputRef . current . ownerDocument ) ;
499
500
const areAllSectionsEmpty = valueManager . areValuesEqual (
500
501
utils ,
501
502
state . value ,
You can’t perform that action at this time.
0 commit comments