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
This commit is contained in:
Tom Moor authored and GitHub committed 2026-06-20 11:11:09 -04:00
1 parent ebf915c840
commit 02001cc2be
11 files changed
+155 -52

No files matched your search

+30 -18
View File
@@ -73,17 +73,14 @@ function Breadcrumb(
const item = actionToMenuItem(action, actionContext) as MenuInternalLink;
return (
<>
<Item
to={item.to}
onClick={handleClick}
$highlight={!!highlightFirstItem && index === 0}
>
{item.icon}
<Item
to={item.to}
onClick={handleClick}
$withIcon={!!item.icon}
$highlight={!!highlightFirstItem && index === 0}
>
{item.title}
</Item>
</>
<Title>{item.title}</Title>
</Item>
);
},
[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<HTMLDivElement, Props>(Breadcrumb));
+1 -1
View File
@@ -76,7 +76,7 @@ const RealButton = styled(ActionButton)<RealProps>`
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
+47 -16
View File
@@ -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 ? (
<CollectionName collection={collection} />
<CollectionName
collection={collection}
icon={<CollectionIcon collection={collection} expanded />}
/>
) : undefined,
section: ActiveDocumentSection,
icon: collection ? (
<CollectionIcon collection={collection} expanded />
) : undefined,
visible: !!(collection && can.readDocument),
to: collection
? {
@@ -152,15 +153,17 @@ function DocumentBreadcrumb(
documentId={node.id}
collection={collection}
title={title}
icon={
node.icon ? (
<Icon
value={node.icon}
color={node.color}
initial={title.charAt(0).toUpperCase()}
/>
) : undefined
}
/>
),
icon: node.icon ? (
<Icon
value={node.icon}
color={node.color}
initial={title.charAt(0).toUpperCase()}
/>
) : 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 (
<ActionContextProvider value={{ activeModels: [collection] }}>
<ContextMenu action={menuAction} ariaLabel={t("Collection options")}>
<span>{collection.name}</span>
<Name>
{icon}
<NameText>{collection.name}</NameText>
</Name>
</ContextMenu>
</ActionContextProvider>
);
});
/** 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 (
<Name>
{icon}
<NameText>{title}</NameText>
</Name>
);
}
return (
@@ -277,12 +292,28 @@ const DocumentName = observer(function DocumentName_({
}}
>
<ContextMenu action={menuAction} ariaLabel={t("Document options")}>
<span>{title}</span>
<Name>
{icon}
<NameText>{title}</NameText>
</Name>
</ContextMenu>
</ActionContextProvider>
);
});
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;
+1 -2
View File
@@ -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")};
}
`;
@@ -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);
}
}
`;
@@ -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};
}
+3 -3
View File
@@ -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;
}
+22 -1
View File
@@ -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 (
<DropdownMenu action={rootAction} ariaLabel={t("Show path to document")}>
<OverflowMenuButton />
<Button />
</DropdownMenu>
);
}
const Button = styled(OverflowMenuButton)`
&& {
width: 32px;
height: 32px;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 4px;
margin-inline: -4px;
transition: background 100ms ease-in-out;
}
&&:hover,
&&[data-state="open"] {
background: ${s("buttonNeutralHoverBackground")};
transition: none;
}
`;
+36 -2
View File
@@ -6,6 +6,7 @@ import { Link } from "react-router-dom";
import useMeasure from "react-use-measure";
import styled, { useTheme } from "styled-components";
import Icon from "@shared/components/Icon";
import { s } from "@shared/styles";
import { altDisplay, metaDisplay } from "@shared/utils/keyboard";
import { publishDocument } from "~/actions/definitions/documents";
import { restoreRevision } from "~/actions/definitions/revisions";
@@ -130,7 +131,7 @@ function DocumentHeader({
shortcut={`Ctrl+${altDisplay}+h`}
placement="bottom"
>
<Button
<TocButton
aria-label={t("Show contents")}
onClick={handleToggle}
icon={<TableOfContentsIcon />}
@@ -182,7 +183,10 @@ function DocumentHeader({
<TableOfContentsMenu />
) : (
<DocumentBreadcrumb document={document}>
{toc} <Star document={document} color={theme.textSecondary} />
{toc}{" "}
<StarAction>
<Star document={document} color={theme.textSecondary} />
</StarAction>
</DocumentBreadcrumb>
)
}
@@ -311,4 +315,34 @@ const StyledHeader = styled(Header)<{ $hidden: boolean }>`
${(props) => props.$hidden && "opacity: 0;"}
`;
const TocButton = styled(Button)`
border-radius: 4px;
&&:hover:not(:disabled),
&&[aria-expanded="true"] {
background: ${s("buttonNeutralHoverBackground")};
box-shadow: none;
transition: none;
}
`;
const StarAction = styled.span`
display: inline-flex;
button {
width: 32px;
height: 32px;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 4px;
transition: background 100ms ease-in-out;
&:hover {
background: ${s("buttonNeutralHoverBackground")};
transition: none;
}
}
`;
export default observer(DocumentHeader);
+1
View File
@@ -166,6 +166,7 @@ declare module "styled-components" {
mentionBackground: string;
mentionHoverBackground: string;
buttonNeutralBackground: string;
buttonNeutralHoverBackground: string;
buttonNeutralText: string;
buttonNeutralBorder: string;
tooltipBackground: string;
+6 -4
View File
@@ -26,7 +26,7 @@ const defaultColors: Colors = {
black75: "rgba(0, 0, 0, 0.75)",
accent: "#0366d6",
yellow: "#EDBA07",
warmGrey: "#EDF2F7",
warmGrey: "hsl(212 31% 95% / 1)",
danger: "#ed2651",
warning: "#f08a24",
success: "#3ad984",
@@ -130,7 +130,7 @@ export const buildLightTheme = (input: Partial<Colors>): DefaultTheme => {
textDiffDeleted: colors.slateDark,
textDiffDeletedBackground: "rgba(255, 180, 173, 0.25)",
placeholder: "#a2b2c3",
sidebarBackground: colors.warmGrey,
sidebarBackground: "hsl(212 31% 95% / 1)",
sidebarHoverBackground: "hsl(212 31% 90% / 1)",
sidebarActiveBackground: "hsl(212 31% 85% / 1)",
sidebarControlHoverBackground: "rgb(138 164 193 / 20%)",
@@ -158,8 +158,9 @@ export const buildLightTheme = (input: Partial<Colors>): DefaultTheme => {
mentionHoverBackground: "#d7e0ea",
tableSelected: colors.accent,
buttonNeutralBackground: colors.white,
buttonNeutralHoverBackground: colors.warmGrey,
buttonNeutralText: colors.almostBlack,
buttonNeutralBorder: darken(0.15, colors.white),
buttonNeutralBorder: "hsl(212 31% 88% / 1)",
tooltipBackground: colors.almostBlack,
tooltipText: colors.white,
toastBackground: colors.white,
@@ -194,7 +195,7 @@ export const buildDarkTheme = (input: Partial<Colors>): DefaultTheme => {
textDiffInsertedBackground: "rgba(63,185,80,0.25)",
textDiffDeleted: darken(0.1, colors.almostWhite),
textDiffDeletedBackground: "rgba(248,81,73,0.15)",
placeholder: "#596673",
placeholder: "hsl(215 17% 30% / 1)",
sidebarBackground: colors.veryDarkBlue,
sidebarHoverBackground: lighten(0.05, colors.veryDarkBlue),
sidebarActiveBackground: lighten(0.09, colors.veryDarkBlue),
@@ -223,6 +224,7 @@ export const buildDarkTheme = (input: Partial<Colors>): DefaultTheme => {
mentionHoverBackground: lighten(0.15, colors.veryDarkBlue),
tableSelected: colors.accent,
buttonNeutralBackground: colors.almostBlack,
buttonNeutralHoverBackground: lighten(0.09, colors.veryDarkBlue),
buttonNeutralText: colors.white,
buttonNeutralBorder: colors.slateDark,
tooltipBackground: colors.white,