fix(website): Make pack button cancel work via keyboard#1585
Conversation
Previously the cancel handler required `event.detail > 0`, so when the button was activated by Enter or Space (which fires a click with `detail === 0`), no cancel was emitted. Switching `type` to `button` while loading prevents the form from submitting, allowing any click event — mouse or keyboard — to signal cancellation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughPackButton prevents form submission during processing by conditionally setting the button type based on loading state, and broadens cancellation handling to treat any interaction as a cancel signal during loading rather than only mouse clicks. ChangesLoading State Form Submission Prevention
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⚡ Performance Benchmark
Details
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
website/client/components/Home/PackButton.vue (1)
31-33: ⚡ Quick winMirror the cancel affordance on focus as well as hover.
Keyboard activation works now, but sighted keyboard users still only see
Processing...because the loading-state affordance switches toCancelon hover only. Add a:focus-visiblevariant so the new keyboard path is discoverable too.Suggested follow-up
.pack-button--loading:hover { background: var(--vp-c-danger-1); } + +.pack-button--loading:focus-visible { + background: var(--vp-c-danger-1); +} -.pack-button--loading:hover .pack-button__text--normal { +.pack-button--loading:hover .pack-button__text--normal, +.pack-button--loading:focus-visible .pack-button__text--normal { opacity: 0; } -.pack-button--loading:hover .pack-button__text--hover { +.pack-button--loading:hover .pack-button__text--hover, +.pack-button--loading:focus-visible .pack-button__text--hover { opacity: 1; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@website/client/components/Home/PackButton.vue` around lines 31 - 33, In PackButton.vue the loading-state affordance only switches to "Cancel" on hover, which hides the keyboard-discoverable signal; update the component's styles and template so the same visual/state change applied on :hover when props.loading is true is also applied for :focus-visible (i.e., add a :focus-visible CSS variant to the same selector that currently handles the loading hover state), ensuring the button remains tabbable and the visible text/icon switches to "Cancel" for keyboard focus as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@website/client/components/Home/PackButton.vue`:
- Around line 31-33: In PackButton.vue the loading-state affordance only
switches to "Cancel" on hover, which hides the keyboard-discoverable signal;
update the component's styles and template so the same visual/state change
applied on :hover when props.loading is true is also applied for :focus-visible
(i.e., add a :focus-visible CSS variant to the same selector that currently
handles the loading hover state), ensuring the button remains tabbable and the
visible text/icon switches to "Cancel" for keyboard focus as well.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f2211c49-fd03-41ac-b050-73884a88d394
📒 Files selected for processing (1)
website/client/components/Home/PackButton.vue
There was a problem hiding this comment.
Code Review
This pull request improves the accessibility of the PackButton component by allowing keyboard users to cancel operations. It achieves this by dynamically switching the button type to 'button' during loading and updating the click handler to process all interaction events. The reviewer suggested further enhancing the user experience by adding :focus-visible styles to provide visual feedback for keyboard navigation, matching the existing hover effects.
| :type="loading ? 'button' : 'submit'" | ||
| @click="handleClick" |
There was a problem hiding this comment.
While this change correctly enables keyboard interaction for cancelling, the visual feedback (changing the background to red and showing the 'Cancel' text) is currently only triggered by the :hover state in the CSS. For a better keyboard experience, consider applying these styles to the :focus-visible state as well, so keyboard users get the same visual cue when the button is focused during processing.
Summary
typetobuttonwhile loading so the form does not submit on Enter/Space.event.detail > 0guard so any click event — mouse or keyboard — emitscancelwhile loading.Why
The previous handler only fired
cancelwhenevent.detail > 0(true for real mouse clicks). When the button was activated via the keyboard, the browser fires a click withdetail === 0, so keyboard users could not cancel an in-flight pack request.Checklist
node --run lint(website/client)