From 02001cc2be90f807a3af00755672d2326edfcb79 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 20 Jun 2026 11:11:09 -0400 Subject: [PATCH] fix: Incorrect sidebar hover state with menu open (#12758) * fix: Incorrect hover state with menu open fix: Pointer pref ignored on sidebarbutton * Normalize header styling --- app/components/Breadcrumb.tsx | 48 ++++++++------ app/components/Button.tsx | 2 +- app/components/DocumentBreadcrumb.tsx | 63 ++++++++++++++----- app/components/Sharing/components/index.tsx | 3 +- .../Sidebar/components/SidebarButton.tsx | 2 +- .../Sidebar/components/SidebarLink.tsx | 11 ++-- app/components/primitives/SplitButton.tsx | 6 +- app/menus/BreadcrumbMenu.tsx | 23 ++++++- app/scenes/Document/components/Header.tsx | 38 ++++++++++- app/typings/styled-components.d.ts | 1 + shared/styles/theme.ts | 10 +-- 11 files changed, 155 insertions(+), 52 deletions(-) diff --git a/app/components/Breadcrumb.tsx b/app/components/Breadcrumb.tsx index a7e4c6369c..7a9296ddd3 100644 --- a/app/components/Breadcrumb.tsx +++ b/app/components/Breadcrumb.tsx @@ -73,17 +73,14 @@ function Breadcrumb( const item = actionToMenuItem(action, actionContext) as MenuInternalLink; return ( - <> + {item.icon} - - {item.title} - - + {item.title} + ); }, [actionContext, handleClick, highlightFirstItem] @@ -109,24 +106,39 @@ const Slash = styled(GoToIcon)` fill: ${s("divider")}; `; -const Item = styled(Link)<{ $highlight: boolean; $withIcon: boolean }>` - ${ellipsis()} +const Item = styled(Link)<{ $highlight: boolean }>` ${undraggableOnDesktop()} + display: flex; + align-items: center; + gap: 4px; flex-shrink: 1; min-width: 0; cursor: var(--pointer); color: ${s("text")}; font-size: 15px; - height: 24px; - line-height: 24px; + height: 32px; font-weight: ${(props) => (props.$highlight ? "500" : "inherit")}; - margin-inline-start: ${(props) => (props.$withIcon ? "4px" : "0")}; - max-width: 460px; + padding-inline: 8px; + border-radius: 4px; + margin-inline: -4px; - &:hover { - text-decoration: underline; + &:first-child { + margin-inline-start: 0; + } + max-width: 460px; + transition: background 100ms ease-in-out; + + &:hover, + &:has([data-state="open"]) { + background: ${s("buttonNeutralHoverBackground")}; + transition: none; } `; +const Title = styled.span` + ${ellipsis()} + min-width: 0; +`; + export default observer(React.forwardRef(Breadcrumb)); diff --git a/app/components/Button.tsx b/app/components/Button.tsx index 50d0cdd5a6..00bd4e725a 100644 --- a/app/components/Button.tsx +++ b/app/components/Button.tsx @@ -76,7 +76,7 @@ const RealButton = styled(ActionButton)` background: ${ props.$borderOnHover ? props.theme.buttonNeutralBackground - : darken(0.05, props.theme.buttonNeutralBackground) + : props.theme.buttonNeutralHoverBackground }; box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 2px, ${ props.theme.buttonNeutralBorder diff --git a/app/components/DocumentBreadcrumb.tsx b/app/components/DocumentBreadcrumb.tsx index aa53d86efc..f93751ffc0 100644 --- a/app/components/DocumentBreadcrumb.tsx +++ b/app/components/DocumentBreadcrumb.tsx @@ -5,6 +5,7 @@ import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; import Icon from "@shared/components/Icon"; +import { ellipsis } from "@shared/styles"; import type Collection from "~/models/Collection"; import type Document from "~/models/Document"; import Breadcrumb from "~/components/Breadcrumb"; @@ -124,12 +125,12 @@ function DocumentBreadcrumb( }), createInternalLinkAction({ name: collection ? ( - + } + /> ) : undefined, section: ActiveDocumentSection, - icon: collection ? ( - - ) : undefined, visible: !!(collection && can.readDocument), to: collection ? { @@ -152,15 +153,17 @@ function DocumentBreadcrumb( documentId={node.id} collection={collection} title={title} + icon={ + node.icon ? ( + + ) : undefined + } /> ), - icon: node.icon ? ( - - ) : undefined, section: ActiveDocumentSection, to: { pathname: node.url, @@ -231,11 +234,13 @@ function DocumentBreadcrumb( ); } -/** Renders a collection name wrapped in a context menu. */ +/** Renders a collection name and icon wrapped in a context menu. */ const CollectionName = observer(function CollectionName_({ collection, + icon, }: { collection: Collection; + icon?: React.ReactNode; }) { const { t } = useTranslation(); const menuAction = useCollectionMenuAction({ @@ -245,21 +250,26 @@ const CollectionName = observer(function CollectionName_({ return ( - {collection.name} + + {icon} + {collection.name} + ); }); -/** Renders a document name wrapped in a context menu. */ +/** Renders a document name and icon wrapped in a context menu. */ const DocumentName = observer(function DocumentName_({ documentId, collection, title, + icon, }: { documentId: string; collection: Collection | undefined; title: string; + icon?: React.ReactNode; }) { const { t } = useTranslation(); const { documents } = useStores(); @@ -267,7 +277,12 @@ const DocumentName = observer(function DocumentName_({ const menuAction = useDocumentMenuAction({ documentId }); if (!doc) { - return <>{title}; + return ( + + {icon} + {title} + + ); } return ( @@ -277,12 +292,28 @@ const DocumentName = observer(function DocumentName_({ }} > - {title} + + {icon} + {title} + ); }); +const Name = styled.span` + display: flex; + align-items: center; + gap: 4px; + min-width: 0; + max-width: 100%; +`; + +const NameText = styled.span` + ${ellipsis()} + min-width: 0; +`; + const SmallSlash = styled(GoToIcon)` width: 12px; height: 12px; diff --git a/app/components/Sharing/components/index.tsx b/app/components/Sharing/components/index.tsx index c1c0c9f537..74a96f9e68 100644 --- a/app/components/Sharing/components/index.tsx +++ b/app/components/Sharing/components/index.tsx @@ -1,4 +1,3 @@ -import { darken } from "polished"; import styled from "styled-components"; import Flex from "@shared/components/Flex"; import { s, hover } from "@shared/styles"; @@ -13,7 +12,7 @@ export { GroupMembersPopover } from "./GroupMembersPopover"; export const Wrapper = styled.div` ${NudeButton}:${hover}, ${NudeButton}[aria-expanded="true"] { - background: ${(props) => darken(0.05, props.theme.buttonNeutralBackground)}; + background: ${s("buttonNeutralHoverBackground")}; } `; diff --git a/app/components/Sidebar/components/SidebarButton.tsx b/app/components/Sidebar/components/SidebarButton.tsx index 1b2a43fe1c..0577521c88 100644 --- a/app/components/Sidebar/components/SidebarButton.tsx +++ b/app/components/Sidebar/components/SidebarButton.tsx @@ -103,6 +103,7 @@ const Button = styled(Flex)<{ text-align: start; user-select: none; position: relative; + cursor: var(--pointer); ${undraggableOnDesktop()} ${extraArea(4)} @@ -119,7 +120,6 @@ const Button = styled(Flex)<{ &[aria-expanded="true"] { color: ${s("sidebarText")}; background: ${s("sidebarActiveBackground")}; - cursor: var(--pointer); } } `; diff --git a/app/components/Sidebar/components/SidebarLink.tsx b/app/components/Sidebar/components/SidebarLink.tsx index 2381c57c27..1f5b96d44c 100644 --- a/app/components/Sidebar/components/SidebarLink.tsx +++ b/app/components/Sidebar/components/SidebarLink.tsx @@ -295,7 +295,6 @@ const Link = styled(NavLink)<{ min-height: 30px; user-select: none; white-space: nowrap; - margin-top: 1px; background: var(--background); color: ${(props) => props.$isActiveDrop ? props.theme.white : props.theme.sidebarText}; @@ -331,7 +330,8 @@ const Link = styled(NavLink)<{ transition: fill 50ms; } - &: ${hover} { + &: ${hover}, + &:has([data-state="open"]) { ${HiddenDisclosure} { display: block; } @@ -349,7 +349,9 @@ const Link = styled(NavLink)<{ `} @media (hover: hover) { - &:hover ${Actions}, &:active ${Actions} { + &:hover ${Actions}, + &:active ${Actions}, + &:has([data-state="open"]) ${Actions} { visibility: visible; svg { @@ -357,7 +359,8 @@ const Link = styled(NavLink)<{ } } - &:hover { + &:hover, + &:has([data-state="open"]) { color: ${(props) => props.$isActiveDrop ? props.theme.white : props.theme.text}; } diff --git a/app/components/primitives/SplitButton.tsx b/app/components/primitives/SplitButton.tsx index e515f4fbca..6e912ce146 100644 --- a/app/components/primitives/SplitButton.tsx +++ b/app/components/primitives/SplitButton.tsx @@ -1,6 +1,6 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { CheckmarkIcon, ExpandedIcon } from "outline-icons"; -import { darken, transparentize } from "polished"; +import { transparentize } from "polished"; import * as React from "react"; import styled, { css } from "styled-components"; import { s } from "@shared/styles"; @@ -185,7 +185,7 @@ const MainButton = styled.button<{ $neutral?: boolean }>` &:hover:not(:disabled) { background: ${(props) => props.$neutral - ? darken(0.05, props.theme.buttonNeutralBackground) + ? props.theme.buttonNeutralHoverBackground : "rgba(0, 0, 0, 0.1)"}; transition: background 0s; } @@ -204,7 +204,7 @@ const DisclosureButton = styled.button<{ $neutral?: boolean }>` &[data-state="open"] { background: ${(props) => props.$neutral - ? darken(0.05, props.theme.buttonNeutralBackground) + ? props.theme.buttonNeutralHoverBackground : "rgba(0, 0, 0, 0.1)"}; transition: background 0s; } diff --git a/app/menus/BreadcrumbMenu.tsx b/app/menus/BreadcrumbMenu.tsx index d6e0cced58..a3821ce1b9 100644 --- a/app/menus/BreadcrumbMenu.tsx +++ b/app/menus/BreadcrumbMenu.tsx @@ -1,4 +1,6 @@ import { useTranslation } from "react-i18next"; +import styled from "styled-components"; +import { s } from "@shared/styles"; import { DropdownMenu } from "~/components/Menu/DropdownMenu"; import { OverflowMenuButton } from "~/components/Menu/OverflowMenuButton"; import { useMenuAction } from "~/hooks/useMenuAction"; @@ -15,7 +17,26 @@ export default function BreadcrumbMenu({ actions }: Props) { return ( - +