From 3ec78371407c239dfa25e084ba261e4c5dd2e99a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 17 Nov 2026 19:09:43 -0500 Subject: [PATCH] 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. --- app/components/Header.tsx | 9 +++++ app/components/Sharing/components/Actions.tsx | 39 +++++++++++++++++-- app/components/Sidebar/Shared.tsx | 17 +++++++- .../Document/components/SharedHeader.tsx | 2 + app/scenes/Shared/Collection.tsx | 9 ++++- 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 4b0d2fa73a..d336b1c7b5 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -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; diff --git a/app/components/Sharing/components/Actions.tsx b/app/components/Sharing/components/Actions.tsx index 5a6802de21..64593114ea 100644 --- a/app/components/Sharing/components/Actions.tsx +++ b/app/components/Sharing/components/Actions.tsx @@ -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 ( + +