docs: fix search bar not focused when using keyboard shortcut (#2999)
* docs: only render mobile search bar on mobile devices * docs: prevent rendering desktop search bar on mobile devices
This commit is contained in:
@@ -9,6 +9,7 @@ import DocSidebarItem from '@theme/DocSidebarItem';
|
||||
import SearchBar from '../../SearchBar';
|
||||
import useIsBrowser from '@docusaurus/useIsBrowser';
|
||||
import AnnouncementBar from '@theme/AnnouncementBar';
|
||||
import {useWindowSize} from '@docusaurus/theme-common';
|
||||
|
||||
function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
|
||||
const {
|
||||
@@ -20,6 +21,7 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
|
||||
} = useThemeConfig();
|
||||
const isBrowser = useIsBrowser()
|
||||
const sidebarRef = useRef(null)
|
||||
const windowSize = useWindowSize();
|
||||
|
||||
useEffect(() => {
|
||||
if (isBrowser && sidebarRef.current) {
|
||||
@@ -55,7 +57,7 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
|
||||
ref={sidebarRef}>
|
||||
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
|
||||
<div className={styles.sidebarSearchContainer}>
|
||||
<SearchBar />
|
||||
{windowSize !== 'mobile' && <SearchBar />}
|
||||
</div>
|
||||
<AnnouncementBar />
|
||||
<Content path={path} sidebar={sidebar} />
|
||||
|
||||
Reference in New Issue
Block a user