Move share search to the header on mobile (#14622)

Hide the sidebar search input and theme toggle on mobile public shares,
add a search icon button to the header instead, show a single header
action as a circle, and keep sidebar items clear of the header.
This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-17 19:09:43 -05:00
1 parent 2ccf74bbdd
commit 3ec7837140
5 files changed
+69 -7

No files matched your search

+9
View File
@@ -238,6 +238,15 @@ const Actions = styled(Flex)`
margin-inline: -4px;
}
/* A single action shows as a circle, like the menu button. */
&:has(> :only-child) {
padding-inline: 0;
}
& > :only-child {
margin-inline: 0;
}
&& [data-variant] {
background: transparent;
box-shadow: none;
+36 -3
View File
@@ -1,6 +1,7 @@
import { useKBar } from "kbar";
import { observer } from "mobx-react";
import { MoonIcon, SunIcon, SubscribeIcon } from "outline-icons";
import { useState } from "react";
import { MoonIcon, SearchIcon, SunIcon, SubscribeIcon } from "outline-icons";
import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import { Action } from "~/components/Actions";
import Button from "~/components/Button";
@@ -11,6 +12,7 @@ import {
} from "~/components/primitives/Popover";
import Tooltip from "~/components/Tooltip";
import { ShareSubscribeForm } from "./ShareSubscribeForm";
import useMobile from "~/hooks/useMobile";
import useStores from "~/hooks/useStores";
import { Theme } from "~/stores/UiStore";
@@ -18,9 +20,10 @@ export const AppearanceAction = observer(() => {
const { t } = useTranslation();
const { ui } = useStores();
const { resolvedTheme, themeOverride } = ui;
const isMobile = useMobile();
// Hide when theme is locked via query parameter
if (themeOverride) {
if (themeOverride || isMobile) {
return null;
}
@@ -50,6 +53,36 @@ export const AppearanceAction = observer(() => {
);
});
/**
* A header button that opens search on public shares, shown only on mobile
* where the sidebar search button is hidden.
*/
export function SearchAction() {
const { t } = useTranslation();
const { query } = useKBar();
const isMobile = useMobile();
const handleClick = useCallback(() => {
query.toggle();
}, [query]);
if (!isMobile) {
return null;
}
return (
<Action>
<Button
icon={<SearchIcon />}
onClick={handleClick}
aria-label={t("Search")}
neutral
borderOnHover
/>
</Action>
);
}
export function SubscribeAction({
shareId,
documentId,
+15 -2
View File
@@ -4,7 +4,9 @@ import { SearchIcon } from "outline-icons";
import { useCallback, useEffect, useMemo } from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import { HEADER_HEIGHT } from "@shared/constants";
import { s } from "@shared/styles";
import { breakpoint } from "@shared/styles/breakpoint";
import { ProsemirrorDataHelper } from "@shared/utils/ProsemirrorDataHelper";
import { metaDisplay, shortcutSeparator } from "@shared/utils/keyboard";
import type Share from "~/models/Share";
@@ -87,7 +89,7 @@ function SharedSidebar({ share }: Props) {
/>
)}
<ScrollContainer topShadow flex>
<TopSection>
<TopSection $hasBranding={brandingAvailable}>
<SearchButton onClick={handleOpenSearch}>
<SearchIcon size={20} />
<SearchLabel>{t("Search")}</SearchLabel>
@@ -128,9 +130,16 @@ const ScrollContainer = styled(Scrollable)`
padding-bottom: 16px;
`;
const TopSection = styled(Flex)`
const TopSection = styled(Flex)<{ $hasBranding: boolean }>`
padding: 8px;
flex-shrink: 0;
/* Search is in the header on mobile. Keep the items clear of the header. */
${breakpoint("mobile", "tablet")`
padding: 0;
min-height: ${(props: { $hasBranding: boolean }) =>
props.$hasBranding ? 0 : HEADER_HEIGHT}px;
`}
`;
const SearchButton = styled.button`
@@ -151,6 +160,10 @@ const SearchButton = styled.button`
border-color: ${s("inputBorderFocused")};
color: ${s("textSecondary")};
}
${breakpoint("mobile", "tablet")`
display: none;
`}
`;
const SearchLabel = styled.span`
@@ -17,6 +17,7 @@ import Flex from "~/components/Flex";
import Header from "~/components/Header";
import {
AppearanceAction,
SearchAction,
SubscribeAction,
} from "~/components/Sharing/components/Actions";
import AuthenticatedIsland from "~/components/Sharing/components/AuthenticatedIsland";
@@ -151,6 +152,7 @@ function SharedDocumentHeader({ document }: Props) {
<SubscribeAction shareId={shareId} documentId={document.id} />
)}
<AppearanceAction />
{hasSidebar && <SearchAction />}
<AuthenticatedIsland
document={document}
share={share}
+7 -2
View File
@@ -22,7 +22,10 @@ import useMobile from "~/hooks/useMobile";
import usePolicy from "~/hooks/usePolicy";
import { collectionPath } from "~/utils/routeHelpers";
import Overview from "../Collection/components/Overview";
import { AppearanceAction } from "~/components/Sharing/components/Actions";
import {
AppearanceAction,
SearchAction,
} from "~/components/Sharing/components/Actions";
type Props = {
collection: CollectionModel;
@@ -30,9 +33,10 @@ type Props = {
function SharedCollection({ collection }: Props) {
const { t } = useTranslation();
const { shareId, showLastUpdated } = useShare();
const { shareId, sharedTree, showLastUpdated } = useShare();
const can = usePolicy(collection);
const isMobile = useMobile();
const hasSidebar = !!sharedTree?.children?.length;
const editAction = (
<Action>
@@ -66,6 +70,7 @@ function SharedCollection({ collection }: Props) {
actions={
<>
<AppearanceAction />
{hasSidebar && <SearchAction />}
{can.update ? editAction : null}
</>
}