Skip to content

Drafts: fix the row's interaction states and name its actions - #753

Merged
nuriapenya merged 3 commits into
WordPress:trunkfrom
nuriapenya:fix/drafts-widget-accessibility
Sep 3, 2026
Merged

Drafts: fix the row's interaction states and name its actions#753
nuriapenya merged 3 commits into
WordPress:trunkfrom
nuriapenya:fix/drafts-widget-accessibility

Conversation

@nuriapenya

@nuriapenya nuriapenya commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

What?

Clicking a draft turned the row dark navy on dark glass, roughly 1.5:1 against the card, so the one row you could no longer read was the one you had just opened. wp-admin repaints every <a> on interaction (a:hover, a:active to #135e96, a:focus to #043959) and those selectors out-specify the widget's own color: inherit. The colour is now restated with the element in the selector, the ring is the widget's rather than core's and moves to :focus-visible, and a press answers with the same 0.985 scale .os-constellation__row uses.

While in there, two more. The row's Trash and Suggest buttons were announcing as unnamed buttons, because <os-button> renders its real <button> in a shadow root and forwards neither the host's aria-label nor its title, and a custom element has no role to carry a label on. The name is slotted instead. And every list refresh emptied the container, so a poll firing while you were tabbed onto a draft dropped focus to the top of the page; the rebuild now puts it back.

Known gap, not fixed here: aria-expanded on the Suggest button has the same problem as the names and cannot be fixed from the widget, because giving the host a role would nest a role="button" around a real button. That needs os-button to forward ARIA to its inner <button>, which would fix every icon-only caller at once.

Screenshots

Before After
Clicked / focused row Screenshot 2026-09-03 at 19 36 34 Screenshot 2026-09-03 at 19 38 00
Row pressed Screenshot 2026-09-03 at 19 38 52 Screenshot 2026-09-03 at 19 38 25

Testing instructions

  1. Add the Drafts widget to the desktop, with at least two drafts.
  2. Click a draft. The row text stays readable throughout, and no ring is left behind once the window opens.
  3. Press and hold on a row. It should dent slightly.
  4. Tab to a row. Ring in the accent, following the row's rounded corner, with the row filled as on hover. Tab again to reach the two icon buttons at full strength.
  5. Leave focus on a draft and blur a window to trigger a refresh. Focus should stay on the same row.
  6. Trash the focused draft. Focus should land on the row that takes its place, not be lost.
Open WordPress Playground Preview

wp-admin repaints every `<a>` on interaction: `a:hover, a:active` to
#135e96 and `a:focus` to #043959. Those selectors out-specify the
widget's own `color: inherit`, so a clicked draft went dark navy on
dark glass, around 1.5:1 against the card it sits on. The one row you
could no longer read was the one you had just opened.

The colour is restated with the element in the selector, so it holds in
every state. The ring is ours for the same reason: core's is the neat
accent on a 2px radius, which fights the row's 8px corner and cannot
promise contrast on a card that is glass over an arbitrary wallpaper.
It moves to :focus-visible, because core rings on :focus and so parked
a ring on the row long after the draft had opened in its window.

That left a press with nothing to say, core's colour swap having gone
out with the rest of the leak. It answers with the same 0.985 scale
`.os-constellation__row` uses: no colour to spend, and it reads under a
finger as well as a pointer.
Trash and Suggest were announcing as unnamed buttons. `<os-button>`
renders its real <button> in a shadow root and forwards neither the
host's aria-label nor its title, and a custom element carries no
implicit role, which makes aria-label on it a prohibited attribute that
assistive tech drops. The name is slotted instead, where
name-from-content finds it, and the Dashicon is hidden from it: a
private-use glyph would otherwise be read out.

Rebuilding the list also threw focus away. Every refresh path lands in
render(), which empties the container, so a poll firing while someone
was tabbed onto a draft dropped them to the top of the page. The
rebuild now records which draft and which control held focus and puts
it back, falling through to the row that took a trashed draft's place
rather than stranding focus on <body>.

The applied state of a suggestion was visual only, a wash and a tinted
✓, with aria-disabled left to say "unavailable" where it meant "that
one landed".
@nuriapenya nuriapenya self-assigned this Sep 3, 2026
A widget can be mounted inside a window's iframe, where the global
`document` is not the one its nodes live in, so focus tracking has to
go through `container.ownerDocument`. Also what
@wordpress/no-global-active-element asks for.
@nuriapenya
nuriapenya marked this pull request as ready for review September 3, 2026 17:48
@nuriapenya
nuriapenya merged commit 02c4784 into WordPress:trunk Sep 3, 2026
5 checks passed
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.

1 participant