Skip to content

fix(ui): make the SDK dialog keyboard and screen-reader accessible - #1944

Open
officialasishkumar wants to merge 1 commit into
coinbase:masterfrom
officialasishkumar:fix/dialog-accessibility
Open

officialasishkumar wants to merge 1 commit into
coinbase:masterfrom
officialasishkumar:fix/dialog-accessibility

Conversation

@officialasishkumar

Copy link
Copy Markdown

Summary

Fixes #1909

The WalletLink snackbar and redirect dialog named in #1909 were removed in the v5 SDK, but the one piece of UI the SDK still injects, the "{app} wants to continue in Coinbase Wallet" dialog shown when the popup is blocked, has the same problems:

  • The close control is a clickable <div> around an <img> with no alt. You can't focus it or operate it from the keyboard, and it has no accessible name.
  • The dialog has no role, no aria-modal, and no accessible name or description.
  • Focus stays on the page behind the backdrop, Tab moves into hidden page content, and Escape does nothing.

This PR changes DialogInstance so that it:

  • renders with role="dialog" and aria-modal="true", using aria-labelledby for the title and aria-describedby for the message. The ids are prefixed so they can't collide with a host page's own Preact useId values.
  • renders the close control as <button type="button" aria-label="Close"> with a decorative icon (alt=""). Action buttons get type="button".
  • moves focus to the first action when it opens, or to Close if there are no actions.
  • keeps Tab and Shift+Tab inside the dialog and pulls focus back in if it has left.
  • closes on Escape through the existing handleClose path, so the request is rejected and telemetry is logged exactly as when Close is clicked. Escape is ignored if the page already called preventDefault() on it.
  • restores focus to the element the page had focused once the dialog unmounts.

Dialog.scss resets the native button padding, border and background, so the close button looks the same as before. Drag-to-dismiss still finds the close control by its class.

How did you test your changes?

  • Added tests in Dialog.test.tsx for: dialog role, name and description; the labelled Close button; Escape, including the case where the page already handled it; initial focus with and without actions; Tab and Shift+Tab wrapping; pulling focus back in; and focus restore on unmount. Without the component change, the 8 positive tests fail.
  • renders hidden initially used to assert that setTimeout was called exactly once. Moving focus makes jsdom queue its own selectionchange timer, so the test now checks that the 1 ms reveal timer is scheduled.
  • yarn test --run (530 tests), tsc --noEmit, biome lint and the format:check command all pass.
  • Built the package and loaded dist/coinbase-wallet-sdk.min.js in headless Chromium with window.open stubbed to return null, then called eth_requestAccounts. The dialog was exposed as a modal named "E2E wants to continue in Coinbase Wallet" and described by its message, and Close was a BUTTON. Focus started on "Try again", and Tab and Shift+Tab wrapped between Close and Cancel. Escape removed the dialog, rejected the request with "Popup window was blocked", and returned focus to the page's Connect button.

The dialog the SDK injects when the wallet popup is blocked could only be
dismissed with a pointer, and assistive technology had no way to tell it
was a dialog:

- The header close control was a clickable <div> wrapping an <img> with
  no alt text, so it was not focusable, not keyboard operable, and had no
  accessible name.
- The dialog had no role, no aria-modal, and no accessible name or
  description, so screen readers announced it as loose text.
- Opening it left focus on the page underneath, Tab walked out of it
  into content hidden behind the backdrop, and Escape did nothing.

DialogInstance now:

- renders with role="dialog" and aria-modal="true", labelled by its
  title and described by its message (ids are prefixed so they cannot
  collide with a host page's own Preact useId values);
- renders the close control as <button type="button" aria-label="Close">
  with a decorative image, and marks action buttons type="button";
- moves focus to the first action (or the close button when there are
  none), keeps Tab and Shift+Tab inside the dialog, pulls focus back in
  if it has left, and closes on Escape through the same handleClose path
  as the close button, unless the page already handled the key;
- restores focus to the element the page had focused once it unmounts.

The SCSS resets the native button padding, border and background so the
close button looks the same as before. The drag-to-dismiss gesture still
finds the close control by its class.

The "renders hidden initially" test asserted setTimeout was called
exactly once. Moving focus makes jsdom queue its own selectionchange
timer, so the test now asserts the 1 ms reveal timer is scheduled
instead of counting jsdom internals.

Fixes coinbase#1909
@officialasishkumar
officialasishkumar requested a review from a team as a code owner November 11, 2026 12:11
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/2
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 2

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Bug: WalletLink SDK UI is not fully keyboard and screen-reader accessible

2 participants