a11y | A17 restore focus on edit cancel - #76
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe edit workflow captures the original Edit button. Cancelling through the Cancel button or Escape removes the textarea and restores focus to that button. DOM tests cover both cancellation paths. The Wave 4 issue map marks A17 and issue 71 as closed. Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@tests/dom/render.test.js`:
- Around line 219-220: Update the Escape KeyboardEvent in the test around the
dispatchEvent call to set cancelable: true, retain a reference to the event, and
assert event.defaultPrevented after settle() so the test verifies the Escape
handler prevents the default action.
🪄 Autofix
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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6f0715ee-75b2-449b-8391-bcc966b58060
📒 Files selected for processing (3)
a11y-audits/8-5-26/wave-4-plan.mdpublic/app.jstests/dom/render.test.js
| q('.message__edit-textarea').dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); | ||
| await settle(); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make the Escape event cancelable in the test.
Line 219 creates a non-cancelable KeyboardEvent. The test would pass even if preventDefault() were removed from public/app.js. Set cancelable: true and assert event.defaultPrevented.
This assessment is based on the supplied test and Escape handler code.
Proposed test update
- q('.message__edit-textarea').dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
+ const event = new KeyboardEvent('keydown', {
+ key: 'Escape',
+ bubbles: true,
+ cancelable: true,
+ });
+ q('.message__edit-textarea').dispatchEvent(event);
+ expect(event.defaultPrevented).toBe(true);📝 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.
| q('.message__edit-textarea').dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); | |
| await settle(); | |
| const event = new KeyboardEvent('keydown', { | |
| key: 'Escape', | |
| bubbles: true, | |
| cancelable: true, | |
| }); | |
| q('.message__edit-textarea').dispatchEvent(event); | |
| expect(event.defaultPrevented).toBe(true); | |
| await settle(); |
🤖 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 `@tests/dom/render.test.js` around lines 219 - 220, Update the Escape
KeyboardEvent in the test around the dispatchEvent call to set cancelable: true,
retain a reference to the event, and assert event.defaultPrevented after
settle() so the test verifies the Escape handler prevents the default action.
Summary
Closes #71 (A17). Cancelling a message edit removed the textarea without putting focus back on Edit, so keyboard users landed on
<body>.Changes
exitEditModefocuses the Edit button after tearing down the editor (same idea ascopyTextrestoring the trigger).Test plan
npm test