Skip to content

Build your personal knowledge base with Trilium Notes

feat(geomap): stand the drawing tools on a rail down the side of the map

Elian Doranf20a3358863e
diff --git a/apps/client/src/widgets/collections/geomap/DrawToolbar.spec.tsx b/apps/client/src/widgets/collections/geomap/DrawToolbar.spec.tsx
new file mode 100644
index 0000000000..0c62ec293f
--- /dev/null
+++ b/apps/client/src/widgets/collections/geomap/DrawToolbar.spec.tsx
@@ -0,0 +1,84 @@
+/**
+ * The rail of drawing tools over a geo map (see DrawToolbar.tsx). What is checked is that every tool
+ * is offered, that a press arms the map and a press on an armed one stands it down, that the armed
+ * tool is worn held down, and that a map that may not be edited refuses them all.
+ */
+import { act } from "preact/test-utils";
+import { describe, expect, it, vi } from "vitest";
+
+import { renderInto } from "../../../test/render";
+import type { DrawTool } from "./DrawShape";
+import DrawToolbar from "./DrawToolbar";
+import { ParentMap } from "./map";
+
+/** Builds the rail over a map, which it asks nothing more of than being there at all. */
+function renderRail({ map = {} as never, isReadOnly = false, drawingTool = null as DrawTool | null } = {}) {
+ const onToggleDrawing = vi.fn();
+ let container: HTMLElement | undefined;
+ act(() => {
+ container = renderInto(
+ <ParentMap.Provider value={map}>
+ <DrawToolbar isReadOnly={isReadOnly} drawingTool={drawingTool} onToggleDrawing={onToggleDrawing} />
+ </ParentMap.Provider>
+ );
+ });
+ if (!container) throw new Error("the rail was not rendered");
+
+ const all = () => [ ...container?.querySelectorAll<HTMLButtonElement>(".geo-draw-toolbar button") ?? [] ];
+ return {
+ onToggleDrawing,
+ buttons: all,
+ group: () => container?.querySelector(".geo-draw-toolbar") ?? null,
+ button: (icon: string) => all().find((b) => b.classList.contains(icon)) ?? null
+ };
+}
+
+/** Every drawing tool on the rail, by the icon its button wears. */
+const DRAW_TOOL_ICONS: { tool: DrawTool; icon: string }[] = [
+ { tool: "line", icon: "bx-vector" },
+ { tool: "polygon", icon: "bx-shape-polygon" },
+ { tool: "rectangle", icon: "bx-shape-square" },
+ { tool: "circle", icon: "bx-shape-circle" }
+];
+
+describe("geo map DrawToolbar", () => {
+ it("offers every drawing tool, wears the armed one as held down, and hands the arming to the map view", () => {
+ for (const { tool, icon } of DRAW_TOOL_ICONS) {
+ const { button, onToggleDrawing } = renderRail();
+
+ expect(button(icon)?.classList.contains("active")).toBe(false);
+ act(() => button(icon)?.click());
+ expect(onToggleDrawing).toHaveBeenCalledWith(tool);
+
+ const armed = renderRail({ drawingTool: tool });
+ expect(armed.button(icon)?.classList.contains("active")).toBe(true);
+ }
+ });
+
+ /**
+ * A column down the leading edge rather than more buttons at the foot, which the scale and the
+ * camera group already fill at phone width (see DrawToolbar.tsx).
+ */
+ it("stands as a column at the middle of the leading edge", () => {
+ const { group, buttons } = renderRail();
+
+ expect(group()?.getAttribute("data-orientation")).toBe("vertical");
+ expect(group()?.getAttribute("data-placement")).toBe("middle-start");
+ expect(buttons()).toHaveLength(DRAW_TOOL_ICONS.length);
+ });
+
+ it("refuses every tool on a map that may not be edited", () => {
+ const { buttons } = renderRail({ isReadOnly: true });
+
+ expect(buttons()).toHaveLength(DRAW_TOOL_ICONS.length);
+ for (const button of buttons()) {
+ expect(button.disabled).toBe(true);
+ }
+ });
+
+ it("stands aside where there is no map at all", () => {
+ const { buttons } = renderRail({ map: null as never });
+
+ expect(buttons()).toHaveLength(0);
+ });
+});
diff --git a/apps/client/src/widgets/collections/geomap/DrawToolbar.tsx b/apps/client/src/widgets/collections/geomap/DrawToolbar.tsx
new file mode 100644
index 0000000000..dc4013813d
--- /dev/null
+++ b/apps/client/src/widgets/collections/geomap/DrawToolbar.tsx
@@ -0,0 +1,57 @@
+import { useContext } from "preact/hooks";
+
+import { t } from "../../../services/i18n";
+import OverlayControlGroup, { OverlayControlButton } from "../../react/OverlayControlGroup";
+import type { DrawTool } from "./DrawShape";
+import { ParentMap } from "./map";
+
+interface DrawToolbarProps {
+ /** The map may not be edited, which is every tool refused at once. */
+ isReadOnly: boolean;
+ /** The tool the map is armed to draw with, if any — its button worn held down. */
+ drawingTool: DrawTool | null;
+ /** Arms the map to draw with the tool, or stands it down again (see index.tsx). */
+ onToggleDrawing: (tool: DrawTool) => void;
+}
+
+/**
+ * The drawing tools, in a column down the leading edge of the map.
+ *
+ * A rail of their own rather than four more buttons on {@link EditToolbar}, because the foot of the
+ * map is full: the scale holds one corner and {@link MapToolbar} the other, and what is left in the
+ * middle at phone width fits about three buttons. The middle of the leading edge is free at every
+ * width, and a column grows into the map's height rather than towards either corner.
+ *
+ * Each button wears the shape its tool draws and no words, the shapes being what there is to say.
+ * The armed tool is shown held down, and its tooltip says what a second press does, as the marker
+ * button's does.
+ */
+export default function DrawToolbar({ isReadOnly, drawingTool, onToggleDrawing }: DrawToolbarProps) {
+ const map = useContext(ParentMap);
+
+ // No rail over a map that could not be drawn (see the WebGL fallback in map.tsx).
+ if (!map) return null;
+
+ return (
+ <OverlayControlGroup className="geo-draw-toolbar" placement="middle-start" vertical overCanvas>
+ {DRAW_TOOLS.map(({ tool, icon, title }) => (
+ <OverlayControlButton
+ key={tool}
+ title={drawingTool === tool ? t("geo-map.draw-cancel") : title()}
+ icon={icon}
+ active={drawingTool === tool}
+ disabled={isReadOnly}
+ onClick={() => onToggleDrawing(tool)}
+ />
+ ))}
+ </OverlayControlGroup>
+ );
+}
+
+/** The tools in the order they stand on the rail, each wearing the shape it draws. */
+const DRAW_TOOLS: { tool: DrawTool; icon: string; title: () => string }[] = [
+ { tool: "line", icon: "bx-vector", title: () => t("geo-map.draw-line") },
+ { tool: "polygon", icon: "bx-shape-polygon", title: () => t("geo-map.draw-polygon") },
+ { tool: "rectangle", icon: "bx-shape-square", title: () => t("geo-map.draw-rectangle") },
+ { tool: "circle", icon: "bx-shape-circle", title: () => t("geo-map.draw-circle") }
+];
diff --git a/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx b/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx
index 7d66de54d3..1f354a6fb2 100644
--- a/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx
+++ b/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx
@@ -1,26 +1,25 @@
/**
* The bar of editing actions over a geo map (see EditToolbar.tsx). What is checked of each button
* is that a press arms the map and a press on an armed one stands it down, that an armed mode is
- * worn as held down, and that a map that may not be edited refuses them all.
+ * worn as held down, and that a map that may not be edited refuses them all. The drawing tools are
+ * on a rail of their own and checked there (see DrawToolbar.spec.tsx).
*/
import { act } from "preact/test-utils";
import { describe, expect, it, vi } from "vitest";
import { renderInto } from "../../../test/render";
-import type { DrawTool } from "./DrawShape";
import EditToolbar from "./EditToolbar";
import { ParentMap } from "./map";
/** Builds the bar over a map, which it asks nothing more of than being there at all. */
-function renderBar({ map = {} as never, isReadOnly = false, placing = false, drawingTool = null as DrawTool | null } = {}) {
+function renderBar({ map = {} as never, isReadOnly = false, placing = false } = {}) {
const onTogglePlacement = vi.fn();
- const onToggleDrawing = vi.fn();
const onAddGpxTrack = vi.fn();
let container: HTMLElement | undefined;
act(() => {
container = renderInto(
<ParentMap.Provider value={map}>
- <EditToolbar isReadOnly={isReadOnly} placing={placing} onTogglePlacement={onTogglePlacement} drawingTool={drawingTool} onToggleDrawing={onToggleDrawing} onAddGpxTrack={onAddGpxTrack} />
+ <EditToolbar isReadOnly={isReadOnly} placing={placing} onTogglePlacement={onTogglePlacement} onAddGpxTrack={onAddGpxTrack} />
</ParentMap.Provider>
);
});
@@ -29,25 +28,14 @@ function renderBar({ map = {} as never, isReadOnly = false, placing = false, dra
const all = () => [ ...container?.querySelectorAll<HTMLButtonElement>(".geo-edit-toolbar button") ?? [] ];
return {
onTogglePlacement,
- onToggleDrawing,
onAddGpxTrack,
buttons: all,
/** The first button, which is the +. */
button: () => all()[0] ?? null,
- /** The drawing tools, one button per tool, standing between the + and the GPX button. */
- drawButton: (icon: string) => all().find((b) => b.classList.contains(icon)) ?? null,
gpxButton: () => all()[all().length - 1] ?? null
};
}
-/** Every drawing tool on the bar, by the icon its button wears. */
-const DRAW_TOOL_ICONS: { tool: DrawTool; icon: string }[] = [
- { tool: "line", icon: "bx-vector" },
- { tool: "polygon", icon: "bx-shape-polygon" },
- { tool: "rectangle", icon: "bx-shape-square" },
- { tool: "circle", icon: "bx-shape-circle" }
-];
-
describe("geo map EditToolbar", () => {
it("offers to add a note, and hands the arming to the map view", () => {
const { button, onTogglePlacement } = renderBar();
@@ -70,19 +58,6 @@ describe("geo map EditToolbar", () => {
expect(onTogglePlacement).toHaveBeenCalledTimes(1);
});
- it("offers every drawing tool, wears the armed one as held down, and hands the arming to the map view", () => {
- for (const { tool, icon } of DRAW_TOOL_ICONS) {
- const { drawButton, onToggleDrawing } = renderBar();
-
- expect(drawButton(icon)?.classList.contains("active")).toBe(false);
- act(() => drawButton(icon)?.click());
- expect(onToggleDrawing).toHaveBeenCalledWith(tool);
-
- const armed = renderBar({ drawingTool: tool });
- expect(armed.drawButton(icon)?.classList.contains("active")).toBe(true);
- }
- });
-
it("offers to bring in a GPX track, and hands the asking to the map view", () => {
const { gpxButton, onAddGpxTrack } = renderBar();
@@ -95,7 +70,7 @@ describe("geo map EditToolbar", () => {
it("refuses every button on a map that may not be edited", () => {
const { buttons } = renderBar({ isReadOnly: true });
- expect(buttons().length).toBeGreaterThan(2);
+ expect(buttons().length).toBe(2);
for (const button of buttons()) {
expect(button.disabled).toBe(true);
}
diff --git a/apps/client/src/widgets/collections/geomap/EditToolbar.tsx b/apps/client/src/widgets/collections/geomap/EditToolbar.tsx
index fd7de026c7..aef1320c0a 100644
--- a/apps/client/src/widgets/collections/geomap/EditToolbar.tsx
+++ b/apps/client/src/widgets/collections/geomap/EditToolbar.tsx
@@ -4,7 +4,6 @@ import { useContext } from "preact/hooks";
import { t } from "../../../services/i18n";
import OverlayControlGroup, { OverlayControlButton } from "../../react/OverlayControlGroup";
-import type { DrawTool } from "./DrawShape";
import { ParentMap } from "./map";
interface EditToolbarProps {
@@ -16,26 +15,14 @@ interface EditToolbarProps {
/** Arms the map for a note to be placed, or stands it down again — the visible counterpart of
* the Escape the instruction toast offers (see index.tsx). */
onTogglePlacement: () => void;
- /** The tool the map is armed to draw with, if any — its button worn held-down like `placing`. */
- drawingTool: DrawTool | null;
- /** Arms the map to draw with the tool, or stands it down again (see index.tsx). */
- onToggleDrawing: (tool: DrawTool) => void;
/** Asks for a GPX file and brings it onto the map (see `addGpxTrack` in index.tsx). */
onAddGpxTrack: () => void;
}
-/** The drawing tools in the order they stand on the bar, each wearing the shape it draws. */
-const DRAW_TOOLS: { tool: DrawTool; icon: string; title: () => string }[] = [
- { tool: "line", icon: "bx-vector", title: () => t("geo-map.draw-line") },
- { tool: "polygon", icon: "bx-shape-polygon", title: () => t("geo-map.draw-polygon") },
- { tool: "rectangle", icon: "bx-shape-square", title: () => t("geo-map.draw-rectangle") },
- { tool: "circle", icon: "bx-shape-circle", title: () => t("geo-map.draw-circle") }
-];
-
/**
* The editing actions, standing in the middle of the map's foot on an {@link OverlayControlGroup} of
- * their own — the surface every group over this map stands on: adding a marker, the drawing tools,
- * and bringing in a GPX track.
+ * their own — the surface every group over this map stands on: adding a marker and bringing in a
+ * GPX track. The drawing tools stand apart, on a rail of their own (see {@link DrawToolbar}).
*
* A group of its own rather than more buttons on {@link MapToolbar}: that one is the camera — how
* close in the map is drawn, how much screen it gets — and what changes the map is another kind of
@@ -48,7 +35,7 @@ const DRAW_TOOLS: { tool: DrawTool; icon: string; title: () => string }[] = [
* is what goes fullscreen (see MapToolbar): the collection bar stays behind, and while the button
* lived there, a fullscreen map could only be added to through its right-click menu.
*/
-export default function EditToolbar({ isReadOnly, placing, onTogglePlacement, drawingTool, onToggleDrawing, onAddGpxTrack }: EditToolbarProps) {
+export default function EditToolbar({ isReadOnly, placing, onTogglePlacement, onAddGpxTrack }: EditToolbarProps) {
const map = useContext(ParentMap);
// No group over a map that could not be drawn (see the WebGL fallback in map.tsx).
@@ -69,19 +56,6 @@ export default function EditToolbar({ isReadOnly, placing, onTogglePlacement, dr
disabled={isReadOnly}
onClick={onTogglePlacement}
/>
- {/* Each tool wears the shape it draws and no words, the pin's name being enough to say
- what the row is for. An armed tool's tooltip says what a second press does, as the
- marker button's does. */}
- {DRAW_TOOLS.map(({ tool, icon, title }) => (
- <OverlayControlButton
- key={tool}
- title={drawingTool === tool ? t("geo-map.draw-cancel") : title()}
- icon={icon}
- active={drawingTool === tool}
- disabled={isReadOnly}
- onClick={() => onToggleDrawing(tool)}
- />
- ))}
<OverlayControlButton
title={t("geo-map.add-gpx-track")}
icon="bx-trip"
diff --git a/apps/client/src/widgets/collections/geomap/index.css b/apps/client/src/widgets/collections/geomap/index.css
index 324bbe874b..2c20a45d32 100644
--- a/apps/client/src/widgets/collections/geomap/index.css
+++ b/apps/client/src/widgets/collections/geomap/index.css
@@ -163,11 +163,12 @@ body[dir=rtl] .geo-map-container {
}
/*
- * Everything the control groups standing over the map have in common — the camera's in the foot
- * corner (MapToolbar) and the editing actions at the middle of the foot (EditToolbar) — said here
- * once for both: the room they keep from the map's edges, the layer they stand on, and the set the
- * map's furniture is dressed in, all under the names the shared group reads (see the overlay buttons
- * in theme-next/forms.css). What is left for each of them to say is the corner it stands at.
+ * Everything the control groups standing over the map have in common — the camera in the foot
+ * corner (MapToolbar), the editing actions at the middle of the foot (EditToolbar), the drawing
+ * tools down the leading edge (DrawToolbar) — said here once for all of them: the room they keep
+ * from the map's edges, the layer they stand on, and the set the map's furniture is dressed in, all
+ * under the names the shared group reads (see the overlay buttons in theme-next/forms.css). What is
+ * left for each of them to say is where it stands.
*
* Set on the groups rather than on the map, so that nothing else standing over the map is dressed
* for a theme the reader did not choose — a marker's preview is the app's own note tooltip, and it
diff --git a/apps/client/src/widgets/collections/geomap/index.tsx b/apps/client/src/widgets/collections/geomap/index.tsx
index 0fff2ba2e1..64adbf9b89 100644
--- a/apps/client/src/widgets/collections/geomap/index.tsx
+++ b/apps/client/src/widgets/collections/geomap/index.tsx
@@ -19,6 +19,7 @@ import ContextMenus from "./ContextMenus";
import { pointPlace } from "./coordinates";
import DetailPane, { PaneSelection } from "./DetailPane";
import DrawShape, { DrawTool } from "./DrawShape";
+import DrawToolbar from "./DrawToolbar";
import EditToolbar from "./EditToolbar";
import GhostPin from "./GhostPin";
import { GPX_MIME, GpxTrack } from "./GpxTrack";
@@ -441,9 +442,12 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig }: ViewM
isReadOnly={isReadOnly}
placing={placement?.mode === "new"}
onTogglePlacement={toggleNotePlacement}
+ onAddGpxTrack={addGpxTrack}
+ />
+ <DrawToolbar
+ isReadOnly={isReadOnly}
drawingTool={placement?.mode === "draw" ? placement.tool : null}
onToggleDrawing={toggleDrawing}
- onAddGpxTrack={addGpxTrack}
/>
<Tooltips selectedNoteId={selection?.noteId ?? null} paneMaximized={paneMaximized} />
{/* The preview under the pointer while a click is armed to mean a place — the note
diff --git a/apps/client/src/widgets/react/OverlayControlGroup.css b/apps/client/src/widgets/react/OverlayControlGroup.css
index cf46f5c93a..92d7c1cfcd 100644
--- a/apps/client/src/widgets/react/OverlayControlGroup.css
+++ b/apps/client/src/widgets/react/OverlayControlGroup.css
@@ -106,6 +106,19 @@
}
}
+/* A rail down one side of the content instead of a bar across it (see `vertical` on
+ OverlayControlGroup). */
+.tn-overlay-control-group[data-orientation="vertical"] {
+ flex-direction: column;
+
+ /* The ends of the run are the top and the bottom now, so the rounding moves with them. The
+ group's own attribute is named as well as the child, to out-specify the row form above. */
+ :where(button):first-child,
+ :where(button):last-child {
+ border-radius: var(--_start-border-radius, 0) var(--_start-border-radius, 0) var(--_end-border-radius, 0) var(--_end-border-radius, 0);
+ }
+}
+
.tn-overlay-control-group[data-placement] {
position: absolute;
}
@@ -134,3 +147,11 @@
margin-inline: auto;
width: fit-content;
}
+
+/* The middle of a side edge, reckoned the way `-center` reckons the middle of a top or bottom one:
+ stretched from one inset to the other, with the margins sharing what the group does not take. */
+.tn-overlay-control-group[data-placement^="middle-"] {
+ inset-block: var(--overlay-group-inset-top, var(--overlay-group-inset)) var(--overlay-group-inset-bottom, var(--overlay-group-inset));
+ margin-block: auto;
+ height: fit-content;
+}
diff --git a/apps/client/src/widgets/react/OverlayControlGroup.spec.tsx b/apps/client/src/widgets/react/OverlayControlGroup.spec.tsx
index 870768425f..9bae4fff81 100644
--- a/apps/client/src/widgets/react/OverlayControlGroup.spec.tsx
+++ b/apps/client/src/widgets/react/OverlayControlGroup.spec.tsx
@@ -203,6 +203,47 @@ describe("OverlayControlGroup", () => {
expect(container.querySelector(".my-group")?.hasAttribute("data-placement")).toBe(false);
});
+ it("stacks into a column when asked, and says so for its own stylesheet to round the right ends", () => {
+ mount(
+ <OverlayControlGroup className="my-rail" placement="middle-start" vertical>
+ <OverlayControlButton title="Draw a path" icon="bx-vector" />
+ <OverlayControlButton title="Draw an area" icon="bx-shape-polygon" />
+ </OverlayControlGroup>
+ );
+
+ const rail = container.querySelector(".my-rail");
+ expect(rail?.getAttribute("data-orientation")).toBe("vertical");
+ expect(rail?.getAttribute("data-placement")).toBe("middle-start");
+ });
+
+ it("leaves a row saying nothing about its direction", () => {
+ mount(
+ <OverlayControlGroup className="my-group" placement="bottom-center">
+ <OverlayControlButton title="Zoom in" icon="bx-plus-circle" />
+ </OverlayControlGroup>
+ );
+
+ expect(container.querySelector(".my-group")?.hasAttribute("data-orientation")).toBe(false);
+ });
+
+ it("opens a column's tooltips sideways, away from the edge it runs down", () => {
+ // Read off the latest call rather than by label: the second render reuses the first
+ // button's element, so the ref the first call was handed answers to the second one's name.
+ const placement = () => staticTooltipSpy.mock.calls.at(-1)?.[1]?.placement;
+ const rail = (placement: "middle-start" | "middle-end") => (
+ <OverlayControlGroup placement={placement} vertical>
+ <OverlayControlButton title="Draw a path" icon="bx-vector" />
+ </OverlayControlGroup>
+ );
+
+ mount(rail("middle-start"));
+ expect(placement()).toBe("right");
+
+ // Against the trailing edge they open the other way, for the same reason.
+ act(() => render(rail("middle-end"), container));
+ expect(placement()).toBe("left");
+ });
+
it("opens the tooltips of a group at the head downwards, away from the edge it stands at", () => {
mount(
<OverlayControlGroup placement="top-end">
diff --git a/apps/client/src/widgets/react/OverlayControlGroup.tsx b/apps/client/src/widgets/react/OverlayControlGroup.tsx
index 3d9bd038b2..a67b3a2923 100644
--- a/apps/client/src/widgets/react/OverlayControlGroup.tsx
+++ b/apps/client/src/widgets/react/OverlayControlGroup.tsx
@@ -9,10 +9,10 @@ import type { ActionButtonProps } from "./ActionButton";
import { useStaticTooltip } from "./hooks";
/**
- * Where a group stands over what it is put on: which edge of it, and where along that edge. Every
- * group over the app's content stands at one of these six.
+ * Where a group stands over what it is put on: which edge of it, and where along that edge. A group
+ * pinned to a side edge stands at the middle of it, which is where a vertical rail goes.
*/
-export type OverlayPlacement = `${"top" | "bottom"}-${"start" | "center" | "end"}`;
+export type OverlayPlacement = `${"top" | "bottom"}-${"start" | "center" | "end"}` | `middle-${"start" | "end"}`;
interface OverlayControlGroupProps {
/**
@@ -31,6 +31,11 @@ interface OverlayControlGroupProps {
* group is pinned to — and is only worth passing for a group placed by hand.
*/
titlePosition?: ActionButtonProps["titlePosition"];
+ /**
+ * Stacks the buttons into a column instead of a row, for a rail down one side of the content.
+ * The rounding of the two ends follows the column, and the tooltips open sideways.
+ */
+ vertical?: boolean;
/**
* Keeps a press on the group from reaching what it stands on, for a group over a canvas that is
* dragged: a map would otherwise take a press on a button for the start of a drag.
@@ -55,14 +60,15 @@ interface OverlayControlGroupProps {
* is a bar of separate buttons on a pane of glass, and it brings its own surface with it. This is a
* single chip with no gaps, and it is what the app's zoom and navigation controls are built from.
*/
-export default function OverlayControlGroup({ placement, className, titlePosition, overCanvas, children }: OverlayControlGroupProps) {
+export default function OverlayControlGroup({ placement, className, titlePosition, vertical, overCanvas, children }: OverlayControlGroupProps) {
return (
<div
className={clsx("tn-overlay-control-group", className)}
data-placement={placement}
+ data-orientation={vertical ? "vertical" : undefined}
onMouseDown={overCanvas ? (e) => e.stopPropagation() : undefined}
>
- <TooltipDirection.Provider value={titlePosition ?? tooltipDirectionFor(placement)}>
+ <TooltipDirection.Provider value={titlePosition ?? tooltipDirectionFor(placement, vertical)}>
{children}
</TooltipDirection.Provider>
</div>
@@ -71,10 +77,15 @@ export default function OverlayControlGroup({ placement, className, titlePositio
/**
* Which way a group's tooltips open, given where it stands: away from the edge it is pinned to, so
- * that a group at the head of the content does not open its tooltips off the top of it. A group
- * placed by hand is taken to stand at the foot, which is where all but one of them do.
+ * that a group at the head of the content does not open its tooltips off the top of it. A vertical
+ * group is pinned to a side edge, so its tooltips open sideways instead. A group placed by hand is
+ * taken to stand at the foot, which is where all but one of them do.
*/
-function tooltipDirectionFor(placement: OverlayPlacement | undefined): ActionButtonProps["titlePosition"] {
+function tooltipDirectionFor(placement: OverlayPlacement | undefined, vertical: boolean | undefined): ActionButtonProps["titlePosition"] {
+ if (vertical) {
+ return placement?.endsWith("-end") ? "left" : "right";
+ }
+
return placement?.startsWith("top-") ? "bottom" : "top";
}