Add autofocus for searchbar (#1408)

This commit is contained in:
Meier Lukas
2023-09-18 19:30:22 +02:00
committed by GitHub
parent 4a30e327a3
commit 141c27cda7
11 changed files with 47 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ type MainHeaderProps = {
headerActions?: React.ReactNode;
contentComponents?: React.ReactNode;
leftIcon?: React.ReactNode;
autoFocusSearch?: boolean;
};
export const MainHeader = ({
@@ -31,6 +32,7 @@ export const MainHeader = ({
headerActions,
leftIcon,
contentComponents,
autoFocusSearch,
}: MainHeaderProps) => {
const { breakpoints } = useMantineTheme();
const isSmallerThanMd = useMediaQuery(`(max-width: ${breakpoints.sm})`);
@@ -51,7 +53,7 @@ export const MainHeader = ({
</UnstyledButton>
</Group>
{!isSmallerThanMd && <Search />}
{!isSmallerThanMd && <Search autoFocus={autoFocusSearch} />}
<Group noWrap style={{ flex: 1 }} position="right">
<Group noWrap spacing={8}>