Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): stop blurring Pause/Resume — reset hoveringFocus directly instead

Adam Eivy261f063e4cce
diff --git a/client/src/components/meatspace/post/DrillTransition.jsx b/client/src/components/meatspace/post/DrillTransition.jsx
index 55e7c2875c..c25725265d 100644
--- a/client/src/components/meatspace/post/DrillTransition.jsx
+++ b/client/src/components/meatspace/post/DrillTransition.jsx
@@ -103,16 +103,18 @@ export default function DrillTransition({ nextDrillType, drillIndex, drillCount,
<div className="flex items-center gap-2">
<button
type="button"
- onClick={(e) => {
+ onClick={() => {
setManuallyPaused(p => !p);
- // Many browsers (Chrome/Edge, Windows Firefox) keep focus on a
- // <button> after a click, which would otherwise leave
- // hoveringFocus=true forever — so clicking "Resume" would never
- // actually resume (paused still true via hoveringFocus even
- // after manuallyPaused flips off). Blur has relatedTarget=null,
- // which the card's onBlur handler treats as "focus left the
- // card", clearing hoveringFocus so paused can go false again.
- e.currentTarget.blur();
+ // Explicitly clear the ambient focus-pause on every toggle rather
+ // than blurring the button: many browsers (Chrome/Edge, Windows
+ // Firefox) keep focus on a <button> after a click, so without
+ // this, hoveringFocus would stay true forever once the button is
+ // focused and clicking "Resume" would never actually resume.
+ // Resetting the flag directly (instead of calling .blur()) keeps
+ // real keyboard focus on the button — a keyboard user doesn't
+ // lose their place — while still letting a later Tab-away-and-
+ // back re-engage the ambient focus-pause normally.
+ setHoveringFocus(false);
}}
aria-pressed={manuallyPaused}
className="flex items-center gap-1.5 px-4 py-3 bg-port-card border border-port-border hover:border-port-accent text-gray-300 text-sm font-medium rounded-lg transition-colors shrink-0"
diff --git a/client/src/components/meatspace/post/DrillTransition.test.jsx b/client/src/components/meatspace/post/DrillTransition.test.jsx
index 561dc2ecf7..37b60fd5ec 100644
--- a/client/src/components/meatspace/post/DrillTransition.test.jsx
+++ b/client/src/components/meatspace/post/DrillTransition.test.jsx
@@ -65,25 +65,28 @@ describe('DrillTransition', () => {
expect(onContinue).toHaveBeenCalledTimes(1);
});
- it('Resume still resumes the countdown when the browser leaves focus on the button after a click', async () => {
+ it('Resume still resumes the countdown when the browser leaves focus on the button after a click, without stealing keyboard focus', async () => {
// Regression: Chrome/Edge/Windows Firefox keep focus on a <button> after
// a real click (jsdom's fireEvent.click does not model this, which is
- // why the previous test alone didn't catch it). Without an explicit
- // blur-on-click, hoveringFocus would stay true forever once the
- // Pause/Resume button is focused, permanently pausing the countdown —
- // clicking "Resume" would never actually resume it.
+ // why an earlier version of this test didn't catch it). Without
+ // resetting hoveringFocus on toggle, it would stay true forever once
+ // the Pause/Resume button is focused, permanently pausing the
+ // countdown — clicking "Resume" would never actually resume it. The fix
+ // must NOT blur the button to work around this — that would strand a
+ // keyboard user's focus — so also assert focus stays on the button.
const onContinue = vi.fn();
render(<DrillTransition {...baseProps} onContinue={onContinue} />);
const pauseButton = screen.getByRole('button', { name: 'Pause' });
act(() => { pauseButton.focus(); });
fireEvent.click(pauseButton);
- expect(document.activeElement).not.toBe(pauseButton);
+ expect(document.activeElement).toBe(pauseButton);
await tickSeconds(5);
expect(onContinue).not.toHaveBeenCalled();
const resumeButton = screen.getByRole('button', { name: 'Resume' });
- act(() => { resumeButton.focus(); });
+ expect(document.activeElement).toBe(resumeButton); // same element, re-labeled
fireEvent.click(resumeButton);
+ expect(document.activeElement).toBe(resumeButton);
await tickSeconds(3);
expect(onContinue).toHaveBeenCalledTimes(1);
});