diff --git a/src/components/DevDocTemplate/index.tsx b/src/components/DevDocTemplate/index.tsx index c18e2435b..32b2bebb7 100644 --- a/src/components/DevDocTemplate/index.tsx +++ b/src/components/DevDocTemplate/index.tsx @@ -98,10 +98,6 @@ const DevDocTemplate: FC = (props) => { // breadcrumsData is derived after processedNavMap is built (see useMemo below) const [activeCategory, setActiveCategory] = useState('guides'); const [showSearch, setShowSearch] = useState(false); - - useEffect(() => { - window.dispatchEvent(new CustomEvent('spotter-code-suspend', { detail: { suspended: showSearch } })); - }, [showSearch]); const [leftNavOpen, setLeftNavOpen] = useState(false); const [keyword, updateKeyword] = useState(''); const [isPublicSiteOpen, setIsPublicSiteOpen] = useState(() => { @@ -461,10 +457,10 @@ const isVersionedIframe = VERSION_DROPDOWN.some( }, content: { top: '50px', - left: 'auto', - right: 'auto', + left: 0, + right: 0, bottom: 'auto', - width: isMaxMobileResolution ? '40%' : '100%', + width: isMaxMobileResolution ? '40%' : 'calc(100% - 32px)', margin: 'auto', transform: 'translate(0, 70px)', border: 'none', @@ -479,6 +475,7 @@ const isVersionedIframe = VERSION_DROPDOWN.some( isOpen={showSearch} onRequestClose={() => setShowSearch(false)} style={customStyles} + portalClassName="DocsSearchModalPortal" >
{ const abortRef = useRef(null); const userScrolledRef = useRef(false); - const [isSuspended, setIsSuspended] = useState(false); - const panelRef = useRef(null); - useEffect(() => { - const handler = (e: CustomEvent<{ suspended: boolean }>) => { - setIsSuspended(e.detail.suspended); - if (e.detail.suspended) { - const active = document.activeElement as HTMLElement | null; - if (active && panelRef.current?.contains(active)) { - active.blur(); - } - } - }; - window.addEventListener('spotter-code-suspend', handler as EventListener); - return () => window.removeEventListener('spotter-code-suspend', handler as EventListener); - }, []); - useEffect(() => { setIsOpen(true); }, []); @@ -239,10 +223,10 @@ const FloatingAssistant: React.FC = () => { }; useEffect(() => { - if (isOpen && !isSuspended && inputRef.current) { + if (isOpen && inputRef.current) { inputRef.current.focus(); } - }, [isOpen, isSuspended]); + }, [isOpen]); useEffect(() => { const el = inputRef.current; @@ -252,10 +236,10 @@ const FloatingAssistant: React.FC = () => { }, [input]); useEffect(() => { - if (quotedText && !isSuspended) { + if (quotedText) { setTimeout(() => inputRef.current?.focus(), 100); } - }, [quotedText, isSuspended]); + }, [quotedText]); useEffect(() => { const handler = (e: CustomEvent<{ location: Location }>) => { @@ -433,14 +417,13 @@ const FloatingAssistant: React.FC = () => { <> {!isOpen && !isClosing && (
@@ -449,8 +432,7 @@ const FloatingAssistant: React.FC = () => { {(isOpen || isClosing) && (