Skip to content

Commit 52b625b

Browse files
matt2eclaude
andcommitted
fix(sessions): hide selected-message actions beyond their pane
The selected session message pane scrolls but lacked the message scroller marker, so its floating toolbar skipped the offscreen guard. A long selected message kept revealed by hover or focus could paint its actions over the "Back to latest" navigation once the anchor left the pane, and those controls still took clicks there. Mark the pane as a message scroller so the shared positioning hides the toolbar when its anchor scrolls out and restores it on return. Add one browser case on the session-navigation fixture that grows the selected message, reveals the toolbar by hover and focus, scrolls its anchor under the navigation, and checks it is hidden, unclickable and back in place after scrolling home. It fails at the previous head in Chromium and WebKit. Assert the pane contract in the component test. Validation: 6 Chromium/WebKit cases in the session-navigation spec, 6 component tests, Biome and TypeScript. Native-app and human acceptance testing remain deferred. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent 70c38b7 commit 52b625b

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

‎src/features/sessions/SessionMessageTarget.test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ it("keeps a verified exact target readable if unrelated thread context fails", a
213213
);
214214
const selected = screen.getByText("Selected reply");
215215
expect(selected).toBeVisible();
216+
// Floating message actions hide once their anchor leaves this scroll pane.
217+
expect(
218+
screen.getByRole("region", { name: "Selected session message" }),
219+
).toHaveAttribute("data-message-scroller");
216220
// Let reveal run before teardown; rendering text alone can outrun its frame.
217221
await waitFor(() =>
218222
expect(selected.closest("[data-message-id]")).toHaveFocus(),

‎src/features/sessions/SessionMessageTarget.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function SelectedMessage({
157157
return (
158158
<section
159159
ref={scroller}
160+
data-message-scroller
160161
className={messages.feed}
161162
aria-label="Selected session message"
162163
>

‎tests/browser/session-navigation.spec.mjs‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,88 @@ test("older session root and reply links fetch and reveal inline, then sending r
9191
await expect(selected(page)).toHaveCount(0);
9292
});
9393

94+
// Browser-only: top-layer painting and hit testing against a real scroll pane.
95+
test("selected message actions hide beyond their pane and return with it", async ({
96+
page,
97+
app,
98+
}) => {
99+
await page.goto(app.origin);
100+
await expect
101+
.poll(() =>
102+
page.evaluate(() => window.fixtureNavigation?.snapshot().status),
103+
)
104+
.toBe("opened");
105+
expect(
106+
await openTarget(page, target(app, app.exact.target.id, app.exact.root.id)),
107+
).toEqual({ status: "opened" });
108+
const pane = selected(page);
109+
const row = pane.locator(`[data-message-id="${app.exact.target.id}"]`);
110+
await expect(row).toBeFocused();
111+
const actions = row.getByRole("group", {
112+
name: "Message actions",
113+
includeHidden: true,
114+
});
115+
const shown = (visible) =>
116+
expect
117+
.poll(() => actions.evaluate((bar) => bar.matches(":popover-open")))
118+
.toBe(visible);
119+
// Fixture replies are short; stand in for a long selected message whose pane
120+
// scrolls well past the toolbar's anchor.
121+
await row.locator(":scope > [data-layout]").evaluate((node) => {
122+
node.style.minHeight = "1600px";
123+
});
124+
await settle(page, pane);
125+
await row.getByText("Exact reply edited", { exact: true }).hover();
126+
await shown(true);
127+
const focused = actions.getByRole("button").first();
128+
await focused.focus();
129+
await page.mouse.move(0, 0);
130+
await shown(true);
131+
const back = page.getByRole("button", {
132+
name: "Back to latest",
133+
exact: true,
134+
});
135+
const backBox = await back.boundingBox();
136+
const point = {
137+
x: backBox.x + backBox.width / 2,
138+
y: backBox.y + backBox.height / 2,
139+
};
140+
// Scroll the anchor up under the selected-message navigation.
141+
await actions.evaluate((bar, point) => {
142+
const section = bar.closest("section");
143+
section.scrollTop +=
144+
bar.parentElement.getBoundingClientRect().top -
145+
point.y +
146+
bar.offsetHeight / 2;
147+
}, point);
148+
await settle(page, pane);
149+
await shown(false);
150+
await expect(actions).toHaveCSS("opacity", "0");
151+
await expect(focused).toBeFocused();
152+
expect(
153+
await back.evaluate(
154+
(button, point) =>
155+
button.contains(document.elementFromPoint(point.x, point.y)),
156+
point,
157+
),
158+
).toBe(true);
159+
await pane.evaluate((section) => {
160+
section.scrollTop = 0;
161+
});
162+
await settle(page, pane);
163+
await shown(true);
164+
await expect
165+
.poll(() =>
166+
actions.evaluate((bar) => {
167+
const rect = bar.getBoundingClientRect();
168+
const slot = bar.parentElement.getBoundingClientRect();
169+
const pane = bar.closest("section").getBoundingClientRect();
170+
return Math.abs(rect.top - slot.top) < 1 && rect.top >= pane.top;
171+
}),
172+
)
173+
.toBe(true);
174+
});
175+
94176
const membershipTest = test.extend({ membershipActivity: true });
95177
membershipTest(
96178
"a loaded session reply reveals in the existing timeline without an exact lookup",

0 commit comments

Comments
 (0)