Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Show the image bar scrollbar while it scrolls

Bitti2feed306c716
diff --git a/src/components/workspace/ImageBar.tsx b/src/components/workspace/ImageBar.tsx
index a5201db..4b00d57 100644
--- a/src/components/workspace/ImageBar.tsx
+++ b/src/components/workspace/ImageBar.tsx
@@ -58,6 +58,22 @@ export const ImageBar = forwardRef<HTMLDivElement | null, {
return () => element.removeEventListener("wheel", wheel);
}, [shown.length]);
+ /* The platform's overlay scrollbar appears for a moving pointer, not for a
+ scroll made in code — which is what the wheel above is — so the bar is
+ marked while it scrolls, by any means, and draws its own scrollbar then. */
+ useEffect(() => {
+ const element = bar.current;
+ if (!element) return;
+ let timer = 0;
+ const scroll = () => {
+ element.classList.add("image-results--scrolling");
+ window.clearTimeout(timer);
+ timer = window.setTimeout(() => element.classList.remove("image-results--scrolling"), 900);
+ };
+ element.addEventListener("scroll", scroll, { passive: true });
+ return () => { element.removeEventListener("scroll", scroll); window.clearTimeout(timer); };
+ }, []);
+
/* Left and Right step the focus along the thumbnails, Home and End jump to
either end, and the bar scrolls to keep the focused one in view. Moving
the focus does not open the image: Enter or Space does, as a click. From
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsx
index f8838c5..7205f3a 100644
--- a/src/components/workspace/ImageEditor.test.tsx
+++ b/src/components/workspace/ImageEditor.test.tsx
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { useState } from "react";
-import { cleanup, createEvent, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { act, cleanup, createEvent, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { promptValue, typePrompt } from "./promptTestUtils";
import { afterEach, expect, it, vi } from "vitest";
import { ImageEditor } from "./ImageEditor";
@@ -567,3 +567,15 @@ it("removes an original with a family only from inside the family, and the leftm
fireEvent.click(remove("View Edited"));
expect(bar()).toEqual(["View Other"]);
});
+
+it("shows the image bar's scrollbar while it scrolls, then hides it again", () => {
+ vi.useFakeTimers();
+ try {
+ setup();
+ const bar = screen.getByLabelText("Generated images");
+ fireEvent.scroll(bar);
+ expect(bar).toHaveClass("image-results--scrolling");
+ act(() => { vi.advanceTimersByTime(1000); });
+ expect(bar).not.toHaveClass("image-results--scrolling");
+ } finally { vi.useRealTimers(); }
+});
diff --git a/src/styles/image-editor.css b/src/styles/image-editor.css
index 1e49b9b..ae411f4 100644
--- a/src/styles/image-editor.css
+++ b/src/styles/image-editor.css
@@ -71,7 +71,10 @@
.image-overlay.drawing, .image-overlay.drawing rect { cursor: crosshair; }
.image-status { display: flex; flex-direction: column; justify-content: center; gap: var(--space-1); min-height: var(--control-sm); padding: 0 var(--space-3); color: var(--text-secondary); font-size: var(--text-xs); border-top: 1px solid var(--line); }
.image-center > .image-error { margin: var(--space-2); }
-.image-results { display: flex; min-height: 82px; gap: var(--space-2); overflow-x: auto; padding: var(--space-2); border-top: 1px solid var(--line); }
+.image-results { display: flex; min-height: 82px; gap: var(--space-2); overflow-x: auto; padding: var(--space-2); border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: transparent transparent; }
+/* A thin scrollbar while the bar scrolls (the wheel scrolls it sideways in
+ code, which the platform's overlay scrollbar does not show for) or is hovered. */
+.image-results:hover, .image-results.image-results--scrolling { scrollbar-color: var(--text-muted) transparent; }
.image-results button { position: relative; flex: 0 0 72px; height: 64px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--panel); }
.image-draft-badge { position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 3px; padding: 2px; background: var(--glass); color: var(--text-primary); font-size: var(--text-xs); }
.image-results button[aria-pressed="true"] { border-color: var(--accent); }