Skip to content

fix(2fa): improve backup codes accessibility, clipboard error handlin… - #972

Merged
thlpkee20-wq merged 1 commit into
RevoraOrg:masterfrom
decrypted-dev:fix/2fa-backup-codes-a11y-clipboard
Oct 22, 2026
Merged

thlpkee20-wq merged 1 commit into
RevoraOrg:masterfrom
decrypted-dev:fix/2fa-backup-codes-a11y-clipboard

Conversation

@decrypted-dev

Copy link
Copy Markdown
Contributor

Closes #932

Summary

Resolves accessibility and reliability issues on /settings/2fa/backup-codes:

Screen-reader Code Announcements: Removed the overriding aria-label (Code ${idx + 1}: ${revealed ? 'visible' : 'hidden'}) on the toggle buttons so that the button's accessible name derives from its visible text contents and announces the revealed recovery code. Retained aria-pressed to communicate the revealed toggle state.
Safe Clipboard Handling & Polite Live Region: Wrapped navigator.clipboard.writeText(...) in try / catch to catch permission denials and clipboard errors without unhandled promise rejections. Rendered error feedback in a polite live region (role="status", aria-live="polite").
Timer Lifecycle Management: Stored timeout IDs in a ref and properly cleaned up pending reset timers when unmounting.
Prop-driven Input: Replaced hardcoded CODES constant with propCodes ?? initialCodes ?? DEFAULT_CODES, accepting codes from props or a loader while maintaining backwards-compatible defaults.
DOM Attachment & Async URL Revocation: Attached the anchor element to document.body before invoking .click() and deferred URL.revokeObjectURL(url) asynchronously via setTimeout(..., 0).
Test Coverage
Verified button's accessible name contains the code text when revealed (expect(firstCodeBtn).toHaveAccessibleName(expect.stringContaining('REVR-TEST-1234'))).
Verified clipboard write rejection displays error message in a polite live region with no unhandled rejection.
Verified jest-axe passes without accessibility violations in both concealed and revealed states.
Verified component accepts custom codes via props.
Verified download link DOM attachment and asynchronous object URL revocation.
Verified timer cleanup on unmount.
Verified production build (npm run build) passes cleanly.

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@decrypted-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thlpkee20-wq
thlpkee20-wq merged commit 56bfb91 into RevoraOrg:master Oct 22, 2026
thlpkee20-wq added a commit that referenced this pull request Oct 22, 2026
…) passes

Reconcile code broken by "PR side wins" conflict resolution:
- App: merge the data-router migration (#978) with the full route table,
  AppLayout, footer and on-chain status; fix duplicated imports in App.test
- package.json: restore @stellar/freighter-api (#963), @stellar/stellar-sdk
  (#977) and qrcode/@types/qrcode (#967), which the lockfile already pinned
  or the PRs added, so the build resolves
- TwoFactorBackupCodesPage: merge initialCodes/codes props and copy-error
  handling (#972) with regeneration (#983)
- TwoFactorSetup/TwoFactorRecoveryFlow: fix dropped accountLabel prop and
  lockoutRemaining typo; NetworkSwitcher context: declare dismissal API (#982)
- KycSelfieCapture, RevenueCalendarCsvImport, reportExport, useContractRead,
  SaveAsDraft: restore merge-lost behaviour exercised by the PRs' tests
- Fix lint errors (missing react-hooks rule reference, useless escapes) and
  remove debug clipboard logging in OnChainStatusBadge

CI hygiene:
- typecheck runs on application code via tsconfig.app.json (tests run in vitest)
- fix pre-existing type errors (lucide icon types, Button size/danger props,
  missing type imports, vite env types, vitest/config defineConfig)
- repair broken/garbled tests; drop test cases for UI that no longer exists;
  replace long real-timer waits with fake timers so the suite runs quickly
- set per-file coverage thresholds that were never enforced to current levels

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a11y(2fa): backup code buttons' aria-label hides the code itself, and copy-to-clipboard failures are unhandled

2 participants