Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Place flyouts by their set width; command bar tooltips and clipping

Bittic7fff89e47bc
diff --git a/src/components/ui/Chrome.tsx b/src/components/ui/Chrome.tsx
index cebabfe..9b0c5ae 100644
--- a/src/components/ui/Chrome.tsx
+++ b/src/components/ui/Chrome.tsx
@@ -69,7 +69,10 @@ export const CommandBarButton = forwardRef(function CommandBarButton(
aria-label={withText ? undefined : label}
aria-pressed={pressed}
aria-keyshortcuts={ariaKeyShortcuts(shortcut)}
- data-tooltip={tooltip ?? (withText && !shortcut ? undefined : label)}
+ /* Always: a labelled button loses its text when the bar is narrow
+ (the stylesheet hides .ui-cmd__label), and then the tooltip is all
+ that names it. */
+ data-tooltip={tooltip ?? label}
data-tooltip-shortcut={shortcut ? formatShortcut(shortcut) : undefined}
{...rest}
>
diff --git a/src/components/ui/Controls.test.tsx b/src/components/ui/Controls.test.tsx
index 7572c4e..65ec9fb 100644
--- a/src/components/ui/Controls.test.tsx
+++ b/src/components/ui/Controls.test.tsx
@@ -157,6 +157,8 @@ describe("CommandBar", () => {
expect(saveButton).toHaveAttribute("aria-keyshortcuts", "Control+S");
expect(screen.getByRole("button", { name: "Snap" })).toHaveAttribute("aria-pressed", "true");
expect(screen.getByRole("button", { name: "Export" })).toHaveTextContent("Export");
+ // Labelled buttons keep a tooltip too: the label is hidden when the bar is narrow.
+ expect(screen.getByRole("button", { name: "Export" })).toHaveAttribute("data-tooltip", "Export");
fireEvent.click(saveButton);
expect(save).toHaveBeenCalled();
saveButton.focus();
@@ -221,6 +223,16 @@ describe("Flyout", () => {
);
}
+ it("places a fixed-width flyout by its real width, so it stays inside the window", () => {
+ // jsdom lays nothing out: offsetWidth is 0, like content measured before
+ // the width applies. The anchor sits near the right edge.
+ const anchor = { left: window.innerWidth - 60, right: window.innerWidth - 28, top: 10, bottom: 42, width: 32, height: 32 };
+ render(<Flyout open anchor={anchor} onClose={() => undefined} aria-label="Queue" width={360}><button>Row</button></Flyout>);
+ const panel = screen.getByRole("dialog", { name: "Queue" });
+ expect(panel.style.width).toBe("360px");
+ expect(parseFloat(panel.style.left) + 360).toBeLessThanOrEqual(window.innerWidth - 8);
+ });
+
it("opens anchored, focuses inside, and light-dismisses", () => {
render(<Anchored />);
const anchor = screen.getByRole("button", { name: "Queue" });
diff --git a/src/components/ui/Flyout.tsx b/src/components/ui/Flyout.tsx
index 0357b45..f4cd31f 100644
--- a/src/components/ui/Flyout.tsx
+++ b/src/components/ui/Flyout.tsx
@@ -44,13 +44,16 @@ const resolveAnchor = (anchor: FlyoutProps["anchor"]): { element: HTMLElement |
export function Flyout({ open, anchor, onClose, children, placement = "bottom", className, initialFocus, width, role = "dialog", ...aria }: FlyoutProps) {
const panel = useRef<HTMLDivElement>(null);
- const [style, setStyle] = useState<CSSProperties>({ visibility: "hidden" });
+ /* The width is on the panel from the first frame, so what is measured below
+ is the size it will have: measured at its content width, a wide flyout
+ was placed as if it were narrow and ran off the right edge. */
+ const [style, setStyle] = useState<CSSProperties>({ visibility: "hidden", width });
const anchorElement = resolveAnchor(anchor).element;
useLayoutEffect(() => {
if (!open || !panel.current) return;
const { rect } = resolveAnchor(anchor);
- const size = { width: panel.current.offsetWidth, height: panel.current.offsetHeight };
+ const size = { width: width ?? panel.current.offsetWidth, height: panel.current.offsetHeight };
const placed = rect ? placeAnchored(rect, size, placement, 4) : { left: 8, top: 8 };
setStyle({ left: placed.left, top: placed.top, width });
focusSafely(initialFocus?.current ?? focusables(panel.current)[0] ?? panel.current);
diff --git a/src/styles/ui.css b/src/styles/ui.css
index 3372dfa..83ef814 100644
--- a/src/styles/ui.css
+++ b/src/styles/ui.css
@@ -1371,6 +1371,17 @@
margin-left: auto;
}
+/* No overflow menu yet: when the bar is too narrow the primary commands are
+ clipped at the end group rather than sliding underneath it. The padding
+ (taken back by the negative margin) keeps the 2px focus ring of the first,
+ last and every button inside the clip. */
+.ui-command-bar__primary {
+ flex: 0 1 auto;
+ overflow: hidden;
+ padding: 3px;
+ margin: -3px;
+}
+
.ui-command-bar__separator {
width: 1px;
height: 20px;
@@ -1695,21 +1706,3 @@
.ui-statusbar__items--end {
margin-left: auto;
}
-
-/* ============================================================================
- Effect bypass (ClipEffects). Parked here by the integration pass because
- timeline.css belonged to another agent at the time; it can move there.
- The checkbox sits in the effect's 32px header ahead of the chevron, and a
- bypassed effect's name reads secondary, the way Premiere dims an fx that
- is switched off.
- ========================================================================== */
-
-.clip-effect__bypass {
- flex: none;
- margin-left: var(--space-2);
- padding-block: 0;
-}
-
-.clip-effect--bypassed .clip-effect__name {
- color: var(--text-secondary);
-}
diff --git a/src/styles/work-queue.css b/src/styles/work-queue.css
index 95f5b27..a3193f0 100644
--- a/src/styles/work-queue.css
+++ b/src/styles/work-queue.css
@@ -11,12 +11,9 @@
button and its InfoBadge.
========================================================================== */
-/* The width is also set here, not only through Flyout's `width` prop: the
- flyout measures itself BEFORE that inline width lands, so without it the
- placement was computed for a narrower panel and the right edge ran off the
- window. */
+/* The 360px width comes from Flyout's `width` prop, which the flyout now
+ places itself by (it used to measure before the width landed). */
.work-queue.ui-flyout {
- width: 360px;
max-width: calc(100vw - 16px);
display: flex;
flex-direction: column;