Skip to content

feat(web): progress pill, inline description, commit animation, new-eyebrow fix - #58

Merged
iskhakovt merged 9 commits into
mainfrom
pr-c-answering-flow
Apr 19, 2026
Merged

iskhakovt merged 9 commits into
mainfrom
pr-c-answering-flow

Conversation

@iskhakovt

@iskhakovt iskhakovt commented Apr 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Question-flow polish bundling the QA round + a few cleanups from review:

QA 4 · Progress link reads as clickable

  • Wraps the top-right "Progress" link in a bordered pill (surface fill, accent hover). Reads as a target, not body text.
  • Unifies Back / Skip hover → accent so all three in-card affordances signal the same way.

QA 5 · Inline description with reserved slot

  • Replaces the "What's this?" toggle with an always-rendered description: muted italic ("hushed inline" treatment after the original quote-rule felt heavier than the content warranted). text-pretty handles orphan avoidance.
  • Reserves 2.75rem under the heading so cards stay uniform whether the question has a description (~43% do) or not.

QA 6 · Suppress "New category" eyebrow when returning

  • Welcome interstitial hides the "New category" eyebrow when the user has answers in that category — no longer reads as "new" on resume. Heading + description still render.

QA 7 · α commit animation + keyboard listener refactor

  • 300ms spring-pop keyframe commit-alpha overshoots and settles into the existing selected-answer ring — keyboard commits now have a visual beat before the advance.
  • Moves number-key handling out of Question.tsx's window listener into two scoped components: RatingGroup (1-5) and a new TimingButtons (1/n, 2/l). Each owns its own useState<Rating | null> + onAnimationEnd-filtered commit flow. Mouse clicks stay instant. Reduced-motion: 1ms keyframe so the commit dispatches without visible motion.

Welcome-screen state-aware CTA

  • Clicking a half-filled category from Summary used to land on the welcome screen and the only Start button took you to the first question — re-walking already-answered ones. Three states now, mirroring /group's vocabulary:
    • fresh (no answers) → Start
    • partial (some answered) → Continue + secondary Review from the start
    • complete (all answered) → Review from the start

New: rating / timing glossary popover (Andrey's QA observation)

  • Andrey lost the rating glossary after the intro screen. A HelpCircle icon next to the Progress pill toggles a popover showing all options with their one-line meanings, sourced from UI.intro.answers / UI.intro.timing (no new copy).
  • Switches content based on the answer mode: rating glossary by default, timing glossary when the Now/Later sub-question is showing.
  • Closes on Escape, click-outside, or the in-popover ×.

Bonus: caching audit todo

  • Surfaced while wiring the welcome CTA logic: existing Summary.tsx and Review.tsx useMemo blocks list answers as a dep but getAnswers() returns fresh object identity each call, so the memos never cache. Filed as a p2 follow-up in todo.md covering useSyncExternalStore migration plus two adjacent cache wins (sortMembersViewerFirst memo, question-by-id Map).

Test coverage added

  • E2E (fill-questionnaire.spec.ts):
    • Description renders inline in the reserved slot (walks to Foundations Q5 = phone-sex).
    • Help popover shows rating glossary; switches to timing glossary on the sub-question.
  • Visual (admin-flow.spec.ts):
    • question-with-description.png (desktop + mobile).
    • question-with-help-popover.png (desktop + mobile, popover open).

Test plan

  • pnpm -r typecheck
  • pnpm test — 23 files / 406 tests
  • pnpm test:e2e — 5/5 in fill-questionnaire (covers new description + help)
  • pnpm test:visual:docker — 18 passed (2 new snapshots × 2 viewports)
  • Manual: press 1-5 during questions, confirm 300ms flash + advance
  • Manual: open help popover on rating screen, commit Yes, confirm popover content swaps to timing
  • Manual: navigate to half-filled category from Summary, confirm "Continue" jumps to first unanswered

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added in-context help popover with glossary information for ratings and timing controls
    • Integrated keyboard shortcuts (1–5) for quick rating selection
  • Improvements

    • Enhanced category navigation with "Continue" (resume where you left off) and "Review from the start" options based on completion status
    • Added visual feedback animation for interaction confirmations
    • Streamlined question interface with simplified description display

@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7e4f66d2-d02a-4569-8a37-46006cd0eaca

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands and usage tips.

@iskhakovt

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@iskhakovt
iskhakovt changed the base branch from pr-b-back-chevron to main April 18, 2026 22:04
…yebrow fix

QA round covering four question-flow issues (#4, #5, #6, #7):

**#4 Progress pill + nav hover**
- Wraps the top-right "Progress" link in a bordered pill so it reads as a
  target, not body text.
- Unifies Back / Skip hover to accent (previously faded-to-muted, almost
  invisible) — all three clickable cues in the card now signal the same
  way.

**#5 Inline description with reserved slot**
- Replaces the "What's this?" toggle with an always-rendered description
  rendered as a muted paragraph with a 2px accent-light left rule
  (editorial-aside style). `text-pretty` handles orphan avoidance.
- Reserves 2.75rem below the heading so cards stay a uniform height
  whether or not the question has a description (~43% do). Removes the
  showDescription state from Question.tsx and the toggle logic it
  carried.

**#6 Suppress "New category" eyebrow when returning**
- The welcome-interstitial eyebrow hid "New category" once the user has
  answers in that category — no longer reads as "new" on resume.
- Threaded via a `hasAnswersInCategory` boolean computed on demand in
  Question.tsx (cheap per-render lookup).

**#7 α commit animation + keyboard listener refactor**
- 300ms spring-pop keyframe `commit-alpha` overshoots and settles into
  the existing selected-answer ring, giving keyboard commits visual
  feedback before the advance fires.
- Moves number-key handling out of Question.tsx's window listener into
  two new scoped components — `RatingGroup` (1-5) and `TimingButtons`
  (1/n, 2/l) — each owning its own `useState<Rating|null>` +
  `onAnimationEnd`-driven commit flow. Listener lifetimes match each
  component's mount, so the two never compete.
- Mouse clicks stay instant (detect via `event.detail === 0`). Reduced-
  motion users get a 1ms keyframe so the commit still dispatches but no
  visible motion plays.
- Page-level arrows (prev/next question) stay in Question.tsx.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@iskhakovt
iskhakovt force-pushed the pr-c-answering-flow branch from 5ce816e to 2c627af Compare April 18, 2026 22:19
iskhakovt and others added 5 commits April 18, 2026 23:31
…lStore

Surfaced while wiring pr-c-answering-flow's welcome-screen CTA logic.
Discovered along the way that existing Summary.tsx + Review.tsx
useMemo blocks depend on `answers` which has fresh object identity
per render — the memos never cache. Promoting from "nice to have" to
p2 because it's actively defeating existing memoization.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ns-by-id map

Two more wins surfaced alongside the useSyncExternalStore item — lump
under the same p2 entry since they're all "do one pass on render-time
computes" work that makes sense batched.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces the 2px accent-light left rule + indent with italic muted
text. The aside-rule felt heavier than the description warranted —
italic carries the "secondary voice" cue with less chrome and stays
closer to the question's typographic line.

No visual baseline change captured because the e2e admin flow narrows
to "Group & External" whose first question has no description.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Clicking a half-filled category from Summary used to land on the
welcome screen and the only Start button took you to the *first*
question of the category — re-walking already-answered ones instead
of resuming where you left off.

Three states now, mirroring the /group screen vocabulary:

  fresh (no answers)        → [Start]
  partial (some answered)   → [Continue]  +  [Review from the start]
  complete (all answered)   → [Review from the start]

Continue jumps to the first unanswered question in the category.
Review from the start jumps to the first question (regardless of
answer state) so the user can walk through edits.

No visual baseline change — e2e admin flow only exercises the fresh
state on the welcome screen.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
QA flagged that the rating glossary disappears after the intro screen
— Andrey forgot what "Fantasy only" meant mid-flow. Adds a small
HelpCircle icon next to the Progress chip in the question card
header. Click toggles a popover showing all rating options
(Yes / If partner wants / Maybe / Fantasy only / No) with their
one-line meanings, sourced verbatim from `UI.intro.answers` so it
matches the intro copy.

Switches content based on context: when the timing sub-question is
showing (Now / Later), the popover swaps to the timing glossary
(`UI.intro.timing`) instead. Closes on Escape, click-outside, or the
in-popover × button. Auto-closes when the answer mode flips.

Tests: e2e asserts both the rating-mode glossary opens and that it
swaps to the timing glossary after committing Yes; visual snapshot of
the open popover is captured alongside the description regression
shot — both desktop and mobile baselines.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web/src/screens/Question.tsx`:
- Around line 164-179: The page-level ArrowLeft/ArrowRight handler in the
useEffect (handleKeyDown in Question.tsx) must ignore events already handled by
child components like RatingGroup in QuestionCard.tsx; modify handleKeyDown to
immediately return when e.defaultPrevented is true (or when event.target is
inside an input/control as needed) so that roving radio focus consumes the arrow
keys first and the window listener does not also navigate between screens.

In `@packages/web/src/screens/QuestionCard.tsx`:
- Around line 81-101: The outside-dismiss effect uses a MouseEvent listener
named onPointerDown and listens for "mousedown", which misses touch/pen input;
update onPointerDown to accept a PointerEvent (change its parameter type from
MouseEvent to PointerEvent), and change the event listener calls to use
"pointerdown" instead of "mousedown" in the useEffect; keep the same guard logic
referencing helpPopoverRef and helpButtonRef and ensure you update both
addEventListener and removeEventListener calls so the listener is properly
cleaned up.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7e50e3a0-2764-4b42-bda2-fed69eb97578

📥 Commits

Reviewing files that changed from the base of the PR and between 798585b and c7303f5.

⛔ Files ignored due to path filters (8)
  • e2e/visual/admin-flow.spec.ts-snapshots/question-timing-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-timing-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-unanswered-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-unanswered-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-with-description-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-with-description-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-with-help-popover-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-with-help-popover-visual-mobile-linux.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • e2e/fill-questionnaire.spec.ts
  • e2e/visual/admin-flow.spec.ts
  • packages/web/src/index.css
  • packages/web/src/screens/CategoryWelcomeScreen.tsx
  • packages/web/src/screens/Question.tsx
  • packages/web/src/screens/QuestionCard.tsx
  • todo.md

Comment on lines +164 to +179
// Page-level keyboard navigation — Arrow left/right only. Rating number
// keys (1-5) and timing keys (1/n, 2/l) are owned by the RatingGroup and
// TimingButtons components in QuestionCard, scoped to their mount.
useEffect(() => {
function handleKeyDown(e: KeyboardEvent) {
if (e.key === "ArrowLeft") {
setIndex((i) => Math.max(0, i - 1));
setShowTiming(false);
setShowDescription(false);
} else if (e.key === "ArrowRight") {
setIndex((i) => Math.min(screens.length, i + 1));
setShowTiming(false);
setShowDescription(false);
} else if (showTiming && (e.key === "1" || e.key === "n")) {
handleTimingRef.current?.("now");
} else if (showTiming && (e.key === "2" || e.key === "l")) {
handleTimingRef.current?.("later");
} else if (!showTiming && keyRatingMap[e.key]) {
handleRatingRef.current?.(keyRatingMap[e.key]);
}
}
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [screens.length, showTiming]);
}, [screens.length]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate and examine the Question.tsx file
fd -t f "Question.tsx" packages/web/src/

# Check the exact lines mentioned (164-179)
sed -n '164,179p' packages/web/src/screens/Question.tsx

Repository: iskhakovt/spreadsheet

Length of output: 795


🏁 Script executed:

# Also check the QuestionCard.tsx to see the RatingGroup implementation
fd -t f "QuestionCard.tsx" packages/web/src/

# Look at lines 275-288 mentioned in the comment
sed -n '275,288p' packages/web/src/screens/QuestionCard.tsx

Repository: iskhakovt/spreadsheet

Length of output: 593


🏁 Script executed:

# Search for RatingGroup component definition and its handleArrowKeyDown method
rg -A 15 "handleArrowKeyDown" packages/web/src/screens/QuestionCard.tsx

Repository: iskhakovt/spreadsheet

Length of output: 1292


🏁 Script executed:

# Check if preventDefault is actually called in the RatingGroup or its parent
rg "preventDefault" packages/web/src/screens/QuestionCard.tsx -B 2 -A 2

Repository: iskhakovt/spreadsheet

Length of output: 846


Honor handled arrow keys before page-level navigation.

RatingGroup already consumes ArrowLeft/ArrowRight for roving radio focus in packages/web/src/screens/QuestionCard.tsx, but this window listener still runs because it ignores e.defaultPrevented. Pressing an arrow key on a focused rating button will move focus and navigate away from the question.

Suggested fix
   useEffect(() => {
     function handleKeyDown(e: KeyboardEvent) {
+      if (e.defaultPrevented) return;
       if (e.key === "ArrowLeft") {
         setIndex((i) => Math.max(0, i - 1));
         setShowTiming(false);
       } else if (e.key === "ArrowRight") {
         setIndex((i) => Math.min(screens.length, i + 1));
         setShowTiming(false);
       }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Page-level keyboard navigation — Arrow left/right only. Rating number
// keys (1-5) and timing keys (1/n, 2/l) are owned by the RatingGroup and
// TimingButtons components in QuestionCard, scoped to their mount.
useEffect(() => {
function handleKeyDown(e: KeyboardEvent) {
if (e.key === "ArrowLeft") {
setIndex((i) => Math.max(0, i - 1));
setShowTiming(false);
setShowDescription(false);
} else if (e.key === "ArrowRight") {
setIndex((i) => Math.min(screens.length, i + 1));
setShowTiming(false);
setShowDescription(false);
} else if (showTiming && (e.key === "1" || e.key === "n")) {
handleTimingRef.current?.("now");
} else if (showTiming && (e.key === "2" || e.key === "l")) {
handleTimingRef.current?.("later");
} else if (!showTiming && keyRatingMap[e.key]) {
handleRatingRef.current?.(keyRatingMap[e.key]);
}
}
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [screens.length, showTiming]);
}, [screens.length]);
// Page-level keyboard navigation — Arrow left/right only. Rating number
// keys (1-5) and timing keys (1/n, 2/l) are owned by the RatingGroup and
// TimingButtons components in QuestionCard, scoped to their mount.
useEffect(() => {
function handleKeyDown(e: KeyboardEvent) {
if (e.defaultPrevented) return;
if (e.key === "ArrowLeft") {
setIndex((i) => Math.max(0, i - 1));
setShowTiming(false);
} else if (e.key === "ArrowRight") {
setIndex((i) => Math.min(screens.length, i + 1));
setShowTiming(false);
}
}
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [screens.length]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/screens/Question.tsx` around lines 164 - 179, The page-level
ArrowLeft/ArrowRight handler in the useEffect (handleKeyDown in Question.tsx)
must ignore events already handled by child components like RatingGroup in
QuestionCard.tsx; modify handleKeyDown to immediately return when
e.defaultPrevented is true (or when event.target is inside an input/control as
needed) so that roving radio focus consumes the arrow keys first and the window
listener does not also navigate between screens.

Comment on lines +81 to +101
// Click-outside + Escape close the help popover. Window-level so the user
// can dismiss from anywhere on the page; the listener tears down with the
// component (and is a no-op while closed).
useEffect(() => {
if (!helpOpen) return;
function onKeyDown(e: KeyboardEvent) {
if (e.key === "Escape") setHelpOpen(false);
}
function onPointerDown(e: MouseEvent) {
const target = e.target as Node;
if (helpPopoverRef.current?.contains(target)) return;
if (helpButtonRef.current?.contains(target)) return;
setHelpOpen(false);
}
window.addEventListener("keydown", onKeyDown);
window.addEventListener("mousedown", onPointerDown);
return () => {
window.removeEventListener("keydown", onKeyDown);
window.removeEventListener("mousedown", onPointerDown);
};
}, [helpOpen]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check if the file exists and examine lines 81-101
cat -n packages/web/src/screens/QuestionCard.tsx | sed -n '75,110p'

Repository: iskhakovt/spreadsheet

Length of output: 1742


🏁 Script executed:

# Also check the full file structure to understand context
wc -l packages/web/src/screens/QuestionCard.tsx

Repository: iskhakovt/spreadsheet

Length of output: 110


🏁 Script executed:

# Search for other event listener patterns in the codebase to understand conventions
rg 'addEventListener.*pointer|addEventListener.*mouse' packages/web/src --type ts --type tsx -A 2

Repository: iskhakovt/spreadsheet

Length of output: 92


🏁 Script executed:

# Check if there's any touch event handling elsewhere
rg 'pointerdown|touchstart' packages/web/src --type ts --type tsx

Repository: iskhakovt/spreadsheet

Length of output: 92


🏁 Script executed:

# Search for event listeners without type flag
rg 'addEventListener.*pointer|addEventListener.*mouse|addEventListener.*touch' packages/web/src -A 2

Repository: iskhakovt/spreadsheet

Length of output: 322


🏁 Script executed:

# Check if any touch handlers exist in the file itself
rg 'touch|pointer|mouse' packages/web/src/screens/QuestionCard.tsx -i

Repository: iskhakovt/spreadsheet

Length of output: 645


🏁 Script executed:

# Check common event handling patterns in components
rg '(pointerdown|pointerup|pointermove|touchstart)' packages/web/src --max-count 20

Repository: iskhakovt/spreadsheet

Length of output: 47


🌐 Web query:

pointerdown vs mousedown touch events best practice 2024

💡 Result:

For handling pointerdown vs mousedown events with touch support, the best practice in 2024-2026 is to use Pointer Events (pointerdown) exclusively instead of mousedown or touchstart. Pointer Events provide a unified, hardware-agnostic API that works seamlessly across mouse, touch, pen/stylus inputs with a single set of handlers, simplifying code and reducing bugs from device-specific logic. Key differences: - mousedown fires on every mouse button press; pointerdown fires only on the first button press (mouse) or contact (touch/pen). - On touchscreens, browsers implicitly capture the pointer on pointerdown, routing subsequent events (move/out/over) to the target element until pointerup/cancel. Use setPointerCapture(pointerId) explicitly for drags, or releasePointerCapture if needed for cross-target movement. - Avoid duplicate events: On touch devices, browsers fire both pointer and legacy (mouse/touch) events; prevent compatibility mouse events by calling preventDefault on pointerdown. Implementation best practices: 1. Use pointerdown/pointermove/pointerup/pointercancel (handle both up and cancel for cleanup). 2. Set CSS touch-action: none (or specific like pan-x) on interactive elements to prevent default browser behaviors (scroll/zoom) without costly JS preventDefault. 3. Track pointers by pointerId (unique per contact) using Map/Set for multi-touch. 4. Feature detect: if ('PointerEvent' in window) { use pointer } else { fallback to mouse/touch }. 5. Prevent text selection: user-select: none; touch-action: none. Example drawing app (works on all devices): canvas.style.touchAction = 'none'; let ongoingTouches = new Map; canvas.addEventListener('pointerdown', (e) => { canvas.setPointerCapture(e.pointerId); // start drawing }); canvas.addEventListener('pointermove', (e) => { if (ongoingTouches.has(e.pointerId)) { // draw line } }); canvas.addEventListener('pointerup', cleanup); canvas.addEventListener('pointercancel', cleanup); This is the modern standard per MDN (universal support in Chrome 55+, Firefox 59+, Safari 13+), eliminating separate mouse/touch code paths.

Citations:


Use pointerdown instead of mousedown for touch device compatibility.

The outside-dismiss handler is wired to mousedown, which does not fire on touch devices. The function is named onPointerDown but only handles mouse events. Change the event type to PointerEvent and the listener to "pointerdown" to support touch, pen, and mouse inputs uniformly (the modern standard for cross-device event handling).

Suggested fix
   useEffect(() => {
     if (!helpOpen) return;
     function onKeyDown(e: KeyboardEvent) {
       if (e.key === "Escape") setHelpOpen(false);
     }
-    function onPointerDown(e: MouseEvent) {
+    function onPointerDown(e: PointerEvent) {
       const target = e.target as Node;
       if (helpPopoverRef.current?.contains(target)) return;
       if (helpButtonRef.current?.contains(target)) return;
       setHelpOpen(false);
     }
     window.addEventListener("keydown", onKeyDown);
-    window.addEventListener("mousedown", onPointerDown);
+    window.addEventListener("pointerdown", onPointerDown);
       return () => {
       window.removeEventListener("keydown", onKeyDown);
-      window.removeEventListener("mousedown", onPointerDown);
+      window.removeEventListener("pointerdown", onPointerDown);
     };
   }, [helpOpen]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Click-outside + Escape close the help popover. Window-level so the user
// can dismiss from anywhere on the page; the listener tears down with the
// component (and is a no-op while closed).
useEffect(() => {
if (!helpOpen) return;
function onKeyDown(e: KeyboardEvent) {
if (e.key === "Escape") setHelpOpen(false);
}
function onPointerDown(e: MouseEvent) {
const target = e.target as Node;
if (helpPopoverRef.current?.contains(target)) return;
if (helpButtonRef.current?.contains(target)) return;
setHelpOpen(false);
}
window.addEventListener("keydown", onKeyDown);
window.addEventListener("mousedown", onPointerDown);
return () => {
window.removeEventListener("keydown", onKeyDown);
window.removeEventListener("mousedown", onPointerDown);
};
}, [helpOpen]);
// Click-outside + Escape close the help popover. Window-level so the user
// can dismiss from anywhere on the page; the listener tears down with the
// component (and is a no-op while closed).
useEffect(() => {
if (!helpOpen) return;
function onKeyDown(e: KeyboardEvent) {
if (e.key === "Escape") setHelpOpen(false);
}
function onPointerDown(e: PointerEvent) {
const target = e.target as Node;
if (helpPopoverRef.current?.contains(target)) return;
if (helpButtonRef.current?.contains(target)) return;
setHelpOpen(false);
}
window.addEventListener("keydown", onKeyDown);
window.addEventListener("pointerdown", onPointerDown);
return () => {
window.removeEventListener("keydown", onKeyDown);
window.removeEventListener("pointerdown", onPointerDown);
};
}, [helpOpen]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/screens/QuestionCard.tsx` around lines 81 - 101, The
outside-dismiss effect uses a MouseEvent listener named onPointerDown and
listens for "mousedown", which misses touch/pen input; update onPointerDown to
accept a PointerEvent (change its parameter type from MouseEvent to
PointerEvent), and change the event listener calls to use "pointerdown" instead
of "mousedown" in the useEffect; keep the same guard logic referencing
helpPopoverRef and helpButtonRef and ensure you update both addEventListener and
removeEventListener calls so the listener is properly cleaned up.

iskhakovt and others added 3 commits April 19, 2026 11:12
PR 58 review caught two real issues:

**Question.tsx ArrowLeft/Right double-handling**
RatingGroup's roving-tabindex onKeyDown calls preventDefault on
ArrowLeft/Right to move focus between rating options. The window-
level page-navigation handler in Question.tsx was firing for the
SAME event, so pressing ArrowLeft on a focused rating both moved
the focus ring AND navigated to the previous question. Add an
`e.defaultPrevented` early return so child handlers consume the
event first.

**QuestionCard help popover dismiss missed touch**
The click-outside handler used `mousedown` + `MouseEvent`. Mobile
browsers do synthesize `mousedown` from touchstart in most cases,
but `pointerdown` is the unified event spec for mouse / touch / pen
and works consistently across input types without relying on compat
shims. Switched event name + parameter type to PointerEvent.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…fety

Five items from the review bundle:

**Dismiss popover on screen-key + mode transitions (item 2).** An open
glossary popover used to linger after the user committed an answer
(advancing to the next question) — overlaying the next screen's
content. A `useEffect` on `[showTiming, screen.key]` closes the
popover on any transition that signals "user moved on": commit,
Back, Skip, category jump, or mode flip. Matches the Slack / GitHub /
Notion convention of closing transient popovers on user action.

**Focus move into popover on open (item 6).** Keyboard-only users
opening the help used to land nowhere — focus stayed on the trigger
and Tab cycled through the page to reach the × button. Added a
`closeRef` forwarded to the close button and a `useEffect` that
focuses it on `helpOpen` true. Non-modal dialog pattern (per
Radix / shadcn), Escape still dismisses from anywhere.

**Viewport safety on popover width (item 7).** `max-w-[calc(100vw-2rem)]`
caps the popover inside the viewport minus a margin, in case future
card padding changes or very narrow devices would otherwise cause
clipping.

**Invariant comment on `e.detail === 0` (item 1).** Added a note about
the programmatic `.click()` gotcha — `element.click()` also reports
`detail === 0`, so test helpers that want to exercise the click path
must use real mouse input (Playwright's locator `.click()` produces
`detail ≥ 1`).

**Drop updater form in CategoryWelcomeScreen (item 4).** `setIndex(() =>
firstQuestionIdx)` → `setIndex(firstQuestionIdx)`. Same for
`goToFirstUnanswered`. Not a change in behavior; updater only needs
the closure form when the setter depends on the previous value.

**New E2E: help popover dismisses on commit and on Skip.** Extends
fill-questionnaire.spec.ts — opens popover, presses "3" (keyboard
commit), asserts dialog gone. Then opens again, clicks Skip, asserts
dialog gone. Covers both transition classes from item 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Review item 4 (deferred from the previous commit). None of the
setIndex calls here depend on the previous value — they jump to a
specific index — so the `() => value` form was noise. Widen the prop
type to accept plain values (matching React's native
Dispatch<SetStateAction<number>> shape) and simplify the three
call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@iskhakovt
iskhakovt enabled auto-merge (squash) April 19, 2026 10:29
@iskhakovt
iskhakovt merged commit 7cae802 into main Apr 19, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.11.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

iskhakovt added a commit that referenced this pull request Apr 19, 2026
Playwright's getByRole defaults to substring matching on `name`, which
caused group-cta.spec.ts to flake after PR #58 introduced a second
"Review from the start" button: `{ name: "Start" }` matched both that
button and the intended "Start" CTA, and the wrong element would
detach mid-click → TimeoutError (3/3 recent main failures, all the
same test + line).

Sweep adds `exact: true` to all 155 call sites that use a string name.
Regex names (7) are left alone — they already express intent
explicitly.

Playwright maintainers (microsoft/playwright#27483) have declined to
change the default, and the documented community practice is per-call
opt-in rather than a fixture wrapper, so the sweep is mechanical.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
iskhakovt added a commit that referenced this pull request Apr 19, 2026
* test(e2e): use exact name matching on getByRole across all specs

Playwright's getByRole defaults to substring matching on `name`, which
caused group-cta.spec.ts to flake after PR #58 introduced a second
"Review from the start" button: `{ name: "Start" }` matched both that
button and the intended "Start" CTA, and the wrong element would
detach mid-click → TimeoutError (3/3 recent main failures, all the
same test + line).

Sweep adds `exact: true` to all 155 call sites that use a string name.
Regex names (7) are left alone — they already express intent
explicitly.

Playwright maintainers (microsoft/playwright#27483) have declined to
change the default, and the documented community practice is per-call
opt-in rather than a fixture wrapper, so the sweep is mechanical.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(e2e): correct Fantasy radio label to match UI string

The sweep to exact matching exposed that answerQuestionsCycling was
targeting a radio named "Fantasy", but the actual UI label is
"Fantasy only" (strings.ts:52). Substring matching had been hiding
this all along.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai coderabbitai Bot mentioned this pull request Apr 19, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant