File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,7 +105,6 @@ export function SearchModal({
105105 const atomicBrowserOcclusion = supportsAtomicBrowserPanelOcclusion ( )
106106 const nativeSurfaceReady = useNativeSurfaceOcclusionReady ( open , 'modal' )
107107 const visuallyOpen = open && nativeSurfaceReady
108- const focusReady = atomicBrowserOcclusion ? visuallyOpen : open
109108 const [ retainNativeSurfaceOcclusion , setRetainNativeSurfaceOcclusion ] = useState ( open )
110109 const nativeSurfaceOcclusionActive =
111110 open || ( atomicBrowserOcclusion && retainNativeSurfaceOcclusion )
@@ -326,8 +325,12 @@ export function SearchModal({
326325 if ( open ) setSearch ( '' )
327326 }
328327
328+ /**
329+ * Focus only once the dialog is actually visible: `.focus()` is a no-op while
330+ * the surface still carries `invisible`, and nothing re-focuses afterwards.
331+ */
329332 useEffect ( ( ) => {
330- if ( ! focusReady || ! inputRef . current ) return
333+ if ( ! visuallyOpen || ! inputRef . current ) return
331334 const nativeInputValueSetter = Object . getOwnPropertyDescriptor (
332335 window . HTMLInputElement . prototype ,
333336 'value'
@@ -337,7 +340,7 @@ export function SearchModal({
337340 inputRef . current . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) )
338341 }
339342 inputRef . current . focus ( )
340- } , [ focusReady ] )
343+ } , [ visuallyOpen ] )
341344
342345 const deferredSearch = useDeferredValue ( search )
343346 const deferredSearchRef = useRef ( deferredSearch )
You can’t perform that action at this time.
0 commit comments