Skip to content

feat(a11y): one focus outline, and forms that start in their first field - #510

Merged
Ardnived merged 8 commits into
mainfrom
feat/touch-focus-a11y
Nov 26, 2026
Merged

Ardnived merged 8 commits into
mainfrom
feat/touch-focus-a11y

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Every control shows the same keyboard focus outline: atoms, the place search, and Mapbox's credits button, logo and canvas.
  • A dialog opens in its first field, or on the dialog itself on a touch-only screen, never on its ×.
  • Tap areas apply on touch-only screens only, and the search box's 20px clear × gets one.
  • feat(a11y): the atlas widget can be used with a keyboard and a screen reader #435 had already covered the rest of the touch ticket: the filter-tag ×, Back, Filters, the calendar button and Show more dates.

Change outline

Contract — keyboard focus and tap areas (docs/embedding.md § Accessibility)

What a host's visitor sees changes, but there is no new parameter, origin, CSP or Permissions-Policy entry.

 every control the widget draws:
-  is reached by Tab … and shows a focus ring where it lands
+  … and shows the same focus outline: a 2px line in the brand colour, inside the control
-  answers to a 44 × 44 tap on a touch screen
+  answers to a 44 × 44 tap on a touch-only screen ((hover: none) and (pointer: coarse))
 Mapbox's own controls:
+  canvas, logo and attribution show the widget's outline, keyboard only; no blue halo

Files — one outline, drawn from globals.css

The per-atom focus-visible:ring-2 ring-focus (three styles) gives way to two utilities.

 src/styles/globals.css
+├── @utility focus-outline   # outline-2 -outline-offset-2 outline-focus inset-ring-4 inset-ring-background
+├── @utility focus-ring      # outline: none; &:focus-visible → focus-outline
 ├── @utility touch-target    # ::after 44px tap area
-│     @media (pointer: coarse)
+│     @media (hover: none) and (pointer: coarse)    # = TOUCH_ONLY_QUERY, config/responsive.ts
+└── .mapboxgl-{ctrl-attrib-button, ctrl-attrib a, canvas, ctrl-logo}:focus-visible → focus-outline
 atoms Button, Checkbox, Chip ×, Disclosure, Link, Select/fieldChrome, Slider, ToggleGroup;
 molecules EventFacts, GeolocationPrompt, ImageCarousel
-  outline-none focus-visible:ring-2 focus-visible:ring-focus [ring-offset-1]
+  focus-ring
 RadioGroup choice card
-  has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus
+  has-[:focus-visible]:focus-outline
 Mapbox/MapSearch.tsx wrapper
+  [&_[class$='--ClearBtn']]:{relative, touch-target, focus-ring}      # the clear ×, by its seeded class suffix
 Mapbox/themes.ts cssText
-  .Geocoder:focus-within { box-shadow: 0 0 0 2px primary-9 }
+  .Geocoder:has(.Input:focus-visible) { focus-outline's drawing }   # seeded class names: no utility reaches it
+  .ClearBtn:focus { border: 0; border-radius: 9999px }               # the library's grey focus box

Behaviour — startInFirstField (src/components/atoms/Modal/Modal.tsx, onOpenAutoFocus)

Radix's default focused the header's ×.

 ModalContent onOpenAutoFocus
+  preventDefault; focus the dialog
+  touch-only screen (TOUCH_ONLY_QUERY) → stay on the dialog          # no keyboard rises unasked
+  first visible enabled input / textarea / [role=combobox] → focus it
+  none yet (a form behind Suspense) → watch the dialog's subtree
+    a field appears while focus is still on the dialog → focus it
+    the viewer moved focus meanwhile → stop watching

Preview

  • Preview pending: the Cloudflare branch alias isn't posted yet. Check it on the app's /search?format=online (press Tab through it, and type in the search box to see the clear ×), and in the component library's Modal ("With a form"), Button and Inputs → Radio Group stories.

Contract impact

docs/embedding.md and CHANGELOG.md change in this PR. The two in-tree hosts, WeMeditateWeb's lib/atlas-embed.ts and the WordPress plugin's templates, set none of this, so neither needs a change.

Test results

  • Lean gate (lint, typecheck, test:run): ✓
  • Adversarial review run locally: 2 should-fix, 2 consider, all four addressed in 78d7b7c
  • New and changed specs: src/styles/focus-ring.test.ts (utility query pinned to TOUCH_ONLY_QUERY, the outline's drawing and the geocoder's copy of it, and no ring in the focus colour anywhere in src/) and Modal.focus.test.tsx (first field, late field, touch-only). Each failed against the defect it covers before passing.
  • pnpm build ✓. pnpm test:a11y gave 3 findings, and main gives the identical 3 locally: the Mapbox logo's tap area, and tab order in the two registration stories.

Manual verification

  1. On a real phone: tap the search box's clear ×, a filter tag's ×, Back, Filters, the calendar button and Show more dates. Each should work on the first tap, and the × on the first filter tag should never take a tap meant for Filters.
  2. With a keyboard: press Tab through /search. The map, Mapbox's logo and credits, find-me, settings, the search box, Filters, Sort, the tags and the cards should all show the same outline. A mouse click should show none.
  3. Open Settings → Report an issue with the keyboard and focus should land in the first field. Tap it on a phone and no keyboard should rise.

Notes for reviewer

  • The spoken class count ("22 classes found") was built and then dropped at the owner's request. That ticket criterion stays open.
  • Drawn pointer-coarse: sizes (44px Buttons, fields, toggle items) still ask (pointer: coarse) alone. A touchscreen laptop therefore gets the larger drawn controls but no invisible tap areas. Redefining the variant with @custom-variant would unify the two but shrink about 25 drawn sizes on such laptops, so it is left as a follow-up.
  • A dialog with no field now opens on the dialog itself rather than its ×. One Tab reaches the ×.
  • Dismissed review findings, with reasons:
    • .ClearBtn { position: relative } would unpin the button: it is statically positioned inside the library's absolute .ActionIcon. Measured: drawn 20×20 at the same spot, with a 45×45 hit area on touch.
    • Forced colours lose the band: the outline survives forced colours, unlike the old box-shadow ring, so this is an improvement. No control sets its own inset ring for the focus state to overwrite.
    • Unscoped Mapbox canvas and logo selectors tie with Mapbox's: Mapbox has no focus rule for either, and the scoping pass prefixes both sheets alike.
Detail
  • The outline is inset (-outline-offset-2), so an overflow clip cannot cut it. A 4px inset ring of the panel colour shows as a 2px band inside the line. The line alone measured 1:1 on the checked choice card and on Register in dark mode, and the band is what keeps them visible (checked in the browser in both themes).
  • @mapbox/[email protected] nests no shadow root, so its clear button can take utilities from MapSearch's wrapper. Only the field's own box, .Geocoder, whose class name is seeded per instance, keeps a rule in the library's theme cssText.
  • The first-field focus was checked in the browser against the real report form, which suspends behind a spinner. With a keyboard, focus lands in textarea#report-field-0. On a touch-only screen it stays on the dialog.

🤖 Generated with Claude Code

Ardnived and others added 6 commits November 26, 2026 11:30
Keyboard focus drew three styles: Button's ring with an offset, every other
atom's ring without one, the geocoder's box-shadow, and Mapbox's blue halo on
its credits button even for a mouse click. A `focus-ring` utility replaces all
of them: a 2px inset outline in the focus colour with a 2px band of the panel's
colour inside it, so it survives an overflow clip and shows on a filled
control of its own hue. `focus-ring.test.ts` refuses a control's own ring.

`touch-target` now asks `useCoarsePointer`'s question, `(hover: none) and
(pointer: coarse)`, so a touchscreen laptop's mouse meets no invisible area.
The geocoder's 20px clear button gains the same 44px area through its sheet.

The Modal atom starts a dialog holding a field in that field rather than on
its ×; on a touch-only screen the dialog itself takes focus, so no keyboard
rises unasked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#501's choice card rings itself with `has-[:focus-visible]:ring-2 ring-focus`
while its radio is hidden behind the icon: a third style, and on the checked
card in dark mode a ring in the fill's own colour. It takes
`focus-ring-within`, the same drawing as `focus-ring` on a box whose focus
lands on a hidden control inside it. The drawing itself is `focus-outline`,
which the Mapbox rules also apply now, since their selectors already name the
state. The drift spec reads a ring behind any focus state, `has-[…]` included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first pass ran Prettier over the whole of src/components/AGENTS.md and
scripts/check-a11y.mjs, re-padding tables and requoting strings no change here
touched. Both now carry only the touch-target query and the focus-outline note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- One `TOUCH_ONLY_QUERY` in `config/responsive.ts`, read by `useCoarsePointer` and the Modal,
  and pinned against `touch-target` by the spec rather than a second literal.
- `focus-outline` is Tailwind's own outline and inset-ring utilities, not a hand-copied
  `--tw-*` shadow stack. The choice card takes it behind `has-[:focus-visible]:`, so the
  one-call-site `focus-ring-within` goes. Of the Mapbox resets only the credits button's halo
  needed one.
- The geocoder's clear button takes `touch-target` and `focus-ring` from `MapSearch`'s wrapper:
  search-js-web nests no shadow root, so the copied `::after` and outline in its sheet go.
- The Modal focuses the dialog, then the first field once one exists, so the report form
  behind its spinner starts in its first field too; a dialog with no field no longer opens
  on its ×. The swallowed `<select>` and hidden fields leave the selector.
- The carousel's touch spacing follows the tap areas it makes room for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running
✋ handed back: review-pr did not finish after 3 attempts

recent dispatches
  • 03:21Z review-pr · attempt 3 · session · timed out
  • 03:21Z review-pr · attempt 3 · session
  • 20:01Z review-pr · attempt 2 · session · timed out
  • 20:01Z review-pr · attempt 2 · session
  • 18:36Z review-pr · attempt 1 · session · timed out

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 26, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 26, 2026
- The Modal's field selector and finder fold into their one caller.
- The component guide points at `TOUCH_ONLY_QUERY` and the focus spec instead of
  restating the query, the outline's mechanism and the spec's rule.
- `focus-ring.test.ts` pins the geocoder field's hand-copied outline against
  `focus-outline`, which its sheet cannot apply.
- MapSearch's wrapper reaches the clear × by its seeded `--ClearBtn` suffix,
  not every `<button>` under it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 002fe37 Nov 26 2026, 08:46 PM

@sydevs-dispatcher sydevs-dispatcher Bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 26, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 26, 2026
# Conflicts:
#	CHANGELOG.md
#	src/components/molecules/ActionRow/ActionRow.tsx
@Ardnived
Ardnived merged commit b5831e1 into main Nov 26, 2026
14 checks passed
@Ardnived
Ardnived deleted the feat/touch-focus-a11y branch November 26, 2026 20:49
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Done in SYDevelopers Technical Roadmap Nov 26, 2026
Ardnived added a commit that referenced this pull request Nov 26, 2026
…t stop

The walk presses Tab once per tabbable element, but a roving-tabindex
group (#501's weekday picker) is one Tab stop holding seven, so on
molecules--form-field the walk outlasted the page, wrapped to ff-name and
reported it as a backwards jump. main has failed the gate since #501
and #510 landed together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 26, 2026
…isitor's own format (#509)

* feat(dates): every date and time through one Intl formatter, in the visitor's own format

Dates and times now go through src/lib/time.ts in regionalLocale(locale):
the browser's first language decides, so an en-GB browser reads
"17:45–18:45" and "Wed 18 Nov", en-US "5:45 – 6:45 PM" and "Wed, Nov 18",
and a browser whose first language is another keeps that language's clock
on the English page (cs-CZ "17:45", a Brazilian browser on en-BR-u-hc-h23).

- Times use timeStyle 'short', so whole hours keep their minutes.
- A range that wraps past midnight and runs 12 hours or more writes both
  day periods ("5:00 PM – 12:00 PM", not "5:00 – 12:00 PM").
- A year joins a date only when it is not this year.
- Callers: useEventDisplay, the filter time labels, ActiveFilterPills,
  SearchFilters (weekdayNames instead of luxon's Info.weekdays), the
  registration dates, and the calendar header; the Schedule-X grid runs
  regional English as en-GB or en-US by date order (scheduleXLocale).
- Distances follow the same locale: miles for a UK or US region.
- src/AGENTS.md gains the "Dates and times" rule.

Main's #380 clock rule is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor: simplify per /simplify pass

- useLocale() returns formatLocale, so callers stop deriving regionalLocale
  themselves, and formatTimePeriods takes it like its siblings. The specs'
  useLocale mocks pin it, so they no longer read the machine's own locale
  (use-event-display.test.ts failed on an en-GB machine).
- formatTimeRange: the wrap-past-midnight join fires only when formatRange
  actually collapsed a day period, reading the separator off the same parts;
  a 24-hour locale keeps its own range and suffix ("17:00–12:00 Uhr").
- wallClock replaces events.ts's hourClock; formatDate drops its test-only
  `now` for luxon's Settings.now; usesMiles and dayFirst lose catches that
  guarded nothing; scheduleXLocale loses an unreachable row.
- Shorter comments and src/AGENTS.md rule; duplicate tests removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(dates): a Portuguese browser keeps the calendar grid in Portuguese

The regional locale hands Schedule-X the browser's own Portuguese tag
(pt-PT, pt), which matched no entry and fell back to en-US. Key the
table by language so every Portuguese tag runs pt-BR, as main did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(dates): state the rule in the spec comments, not who asked for it

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(dates): a webview with no navigator.languages formats in the page's locale

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(i18n): formatLocale formats, and is never a locale the widget fetches

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): link the date-format entry to #509

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(calendar): Schedule-X's locale lives with the calendar shaping, not the formatters

scheduleXLocale is calendar configuration with one caller, so it moves from
lib/time.ts into lib/shape/calendar.ts beside the other Schedule-X helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(dates): the dates rule names the module, not its exports

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y-gate): end the keyboard walk when Tab wraps back to the first stop

The walk presses Tab once per tabbable element, but a roving-tabindex
group (#501's weekday picker) is one Tab stop holding seven, so on
molecules--form-field the walk outlasted the page, wrapped to ff-name and
reported it as a backwards jump. main has failed the gate since #501
and #510 landed together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y-gate): index the last stop so the walk typechecks

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y-gate): an unstamped keyboard stop is not a jump to the top

A stop the page rendered after the audit carries no data-a11y-order, and
Number(null) is 0, so views--event-·-sticky-register failed tab-order at
random whenever the audit read the story before it finished rendering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher sydevs-dispatcher Bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 27, 2026
@sydevs-dispatcher

Copy link
Copy Markdown
Contributor

The session for review-pr did not finish after 3 attempts. I have stopped retrying. A @sydevs-bot verb or mention from you starts me again.

🤖 sydevs dispatcher

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant