Make WordPress Core

Opened 6 years ago

Last modified 4 weeks ago

#52399 accepted task (blessed)

Remove widget accessibility mode

Reported by: joedolson Owned by: joedolson
Priority: normal Milestone: 7.3
Component: Widgets Version:
Severity: normal Keywords: needs-design has-patch has-unit-tests
Cc: Focuses: ui, accessibility, administration

Description

With the introduction of the new block editing experience for widgets management, WordPress will have four separate interfaces for managing widgets: block editing, customizer, classic widgets, and accessbility mode.

The accessibility team would like to explore merging the characteristics that accessibility mode uses for better accessibility into the classic widget screen, to cut down to only three modes of operation for widgets.

This will require identifying the characteristics of accessibility mode and finding ways to reproduce those characteristics within the existing widget UI.

The key differences that are obvious are:

1) Use of a text link to 'Add' or 'Edit'
2) Links target each widget via a URL to manage independently.
3) Selection options to choose which sidebar and position will be used for a widget.

These characteristics allow a single widget to be edited in isolation, the ability to assign a location without drag and drop, and visible text tools for handling widgets.

One possibility to explore is having an add/edit option that opens a given widget in a modal that includes the location selection tools provided in accessibility mode.

Attachments (3)

pr14230-trunk-tab.png​ (1.4 KB ) - added by rejaulalomkhan 4 weeks ago.
PR 14230 testing: trunk, Search widget after tabbing past its toggle (no link)
pr14230-edit-focus.png​ (2.0 KB ) - added by rejaulalomkhan 4 weeks ago.
PR 14230 testing: Edit link visible on keyboard focus
pr14230-add-focus.png​ (3.5 KB ) - added by rejaulalomkhan 4 weeks ago.
PR 14230 testing: Add link in Available Widgets on keyboard focus

Download all attachments as: .zip

Change History (34)

#1 @joedolson
6 years ago

  • Owner set to joedolson
  • Status new → accepted

This ticket was mentioned in ​Slack in #accessibility by ryokuhi. ​View the logs.


6 years ago

This ticket was mentioned in ​Slack in #accessibility by ryokuhi. ​View the logs.


6 years ago

#4 @sabernhardt
6 years ago

  • Milestone Awaiting Review → Future Release

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


5 years ago

#6 @joedolson
5 years ago

  • Milestone Future Release → 5.9

This ticket was mentioned in ​Slack in #accessibility by ryokuhi. ​View the logs.


5 years ago

This ticket was mentioned in ​Slack in #accessibility by ryokuhi. ​View the logs.


5 years ago

#9 @ryokuhi
5 years ago

We reviewed this ticket today during the accessibility team's bug scrub.

To sum up the discussion, the team agreed that the final goal for this ticket is to have a single classic widget screen which is accessible by default. This will need work in two directions:

  • reach feature parity by adding features that are currently only available in accessibility mode to the classic widget screen (as pointed out in the ticket description above);
  • solve accessibility issues currently found in the classic widget screen.

This ticket will probably be better addressed if split into smaller chunks, to make progress little by little. But first, it's better to list all accessibility issues that can be found in the classic widget screen. To do so, testing the classic widget screen with and without assistive technologies would help in finding existing bugs.

Since WordPress 5.8, the new Block Widget screen is the default, so to test the old classic widget screen you'll have to install the ​Classic Widgets ​plugin, which is available in the plugin repository and can be installed using your preferred method (either by downolading and uploading it or by installing it directly from the admin screen).

This ticket was mentioned in ​Slack in #accessibility by ryokuhi. ​View the logs.


5 years ago

#11 @sabernhardt
5 years ago

  • Milestone 5.9 → Future Release

I'm setting this to Future Release. If we can solve any specific problems in the classic widget screen for 5.9, that could be addressed in a new ticket.

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


2 years ago

#13 @joedolson
2 years ago

Assigning to @rcreators for research and follow up.

#14 @joedolson
2 years ago

  • Owner changed from joedolson to rcreators
  • Status accepted → assigned

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


11 months ago

#16 @sanket.parmar
7 months ago

I spent some time doing a thorough code audit for this.

How accessibility mode works today (code-level)

The toggle lives in wp-admin/widgets-form.php. When widgets_access = 'on' is stored via set_user_setting(), it adds the widgets_access body class and — critically — skips enqueuing admin-widgets entirely, so drag-and-drop JS is never loaded. The accessible single-widget edit experience lives at widgets.php?editwidget=<id>, rendered by wp-admin/includes/widgets.php, and is fully server-side.

The .widget-control-edit a (Edit/Add link) is already rendered in the markup for every widget in both modes; it is hidden in standard mode only by the hide-if-js class on that element.

Proposed approach (phased)

Phase 1 — Immediate, low risk: Remove hide-if-js from .widget-control-edit a in wp_widget_control(). This makes the Edit/Add text link permanently visible alongside the JS expand button. Keyboard and AT users get a plain-text path to the accessible single-widget edit page without needing to enable a mode. No JS changes required.

Phase 2 — Address standard screen a11y gaps: Two gaps exist in admin-widgets JS that accessibility mode currently sidesteps by not loading JS at all:

  • No wp.a11y.speak() call after AJAX save or delete (only "Add" has one, at line ~706 of widgets.js).
  • Focus is dropped to <body> after widget delete — no focus restore logic exists in that code path.

Both should be fixed before the mode toggle is removed, so the standard screen is actually equivalent.

Phase 3 — Remove the toggle: Once Phases 1–2 land, wp_widgets_access_body_class() becomes unused. It should be deprecated with _deprecated_function() and kept as a no-op for one major version — third-party plugins may target that body class in their CSS.

Two smaller issues found along the way

The help tab text reads: "Enabling Accessibility Mode, via Screen Options" — the toggle has never been in Screen Options, it is a link under the page heading. Independent doc bug.

$_GET['editwidget'] in widgets-form.php (~line 228) is used unsanitized as an array key. No injection vector today since it only does a $wp_registered_widget_controls[$widget_id] lookup, but sanitize_key() would be consistent with how $_POST['widget-id'] is handled elsewhere.

Testing note

Since 5.8 the classic widget screen only appears with the Classic Widgets plugin active or remove_theme_support('widgets-block-editor'), so any test setup needs to account for that.

Happy to put together a patch starting with Phase 1 if that direction looks good to the accessibility team.

#17 @joedolson
4 months ago

Thanks for doing that exploration, @sanketparmar!

I don't know how I missed seeing your message for 2 months, but...here we are.

Feel free to start work on a patch; I'll be happy to help out with that.

#18 @joedolson
4 months ago

  • Owner changed from rcreators to joedolson
  • Status assigned → accepted

This ticket was mentioned in ​PR #12686 on ​WordPress/wordpress-develop by ​@irozum.


4 months ago
#19

  • Keywords has-patch has-unit-tests added; needs-patch removed

This is Phase 1 of the phased plan proposed by @sanketparmar in comment:16 and endorsed by @joedolson in comment:17 — it does not remove Accessibility Mode itself (that depends on Phases 2 and 3 landing first). On the classic Widgets screen (wp-admin/widgets.php), each widget already renders a plain-text "Edit"/"Add" link (.widget-control-edit) pointing at the accessible single-widget edit screen, alongside the JS-only expand/collapse toggle button. That text link was previously hidden whenever JavaScript is available via the hide-if-js class, so keyboard and assistive-technology users had no way to reach the accessible single-widget edit screen without first switching into Accessibility Mode. This change removes hide-if-js from the link in wp_widget_control() so it stays visible alongside the toggle button. Removing that class alone left the link stacking below the toggle button instead of sitting beside it (both are children of the floated .widget-title-action container, and the link's display: block forced a line break), so a small CSS rule was added scoping the link to display: inline-block specifically when it's rendered next to the toggle button; Accessibility Mode's existing higher-specificity override (.widgets_access #wpwrap .widget-control-edit { display: block; }) is unaffected since it hides the toggle button entirely in that mode. Verified manually in the browser with the Classic Widgets plugin active, in both standard and Accessibility Mode, and against the existing and new PHPUnit coverage in tests/phpunit/tests/widgets.php.

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Implementation, tests, browser verification, and PR description. Reviewed by Igor Rozum.

#20 @joedolson
4 months ago

  • Milestone Future Release → 7.2

#21 @sanket.parmar
3 months ago

Thanks for picking up Phase 1, @irozum — this matches the plan from comment:16, and the implementation is accurate.

I reviewed PR ​https://github.com/WordPress/wordpress-develop/pull/12686 against the current source and it holds up:

  • Removing hide-if-js from the .widget-control-edit link in wp_widget_control() is the right one-line change. The link is already rendered for every widget and is hidden purely by that CSS class; no JS in admin-widgets.js touches it, so this is a clean CSS-only reveal.
  • The layout rule is genuinely needed. .widget-control-edit is display: block inside the floated .widget-title-action, so without a fix it stacks below the toggle button. Scoping .widget-title-action .widget-control-edit to inline-block fixes that, and Accessibility Mode's existing .widgets_access #wpwrap .widget-control-edit { display: block; } still wins on specificity, so that mode is unaffected.
  • The .edit/.add spans won't both show — the context CSS (#widgets-right ... .add, #available-widgets ... .edit) already hides the wrong one per zone.

Two things worth confirming before this lands:

  1. Scope note: wp_widget_control() also renders the items in the available-widgets palette, so this change additionally surfaces the plain-text "Add" link on every palette widget in standard mode, not just the "Edit" link on assigned widgets. That's consistent with the accessible add-without-drag goal, but it's a wider surface than the PR description mentions and is worth calling out for testing.
  2. Design sign-off: in standard mode, sighted mouse users now see two affordances per widget — the inline expand button and a text link that navigates to the separate single-widget screen. Surfacing it for all users (rather than AT-only) is the pragmatic call and I think the right one, but since this ticket is needs-design, it'd be good to get @joedolson's explicit sign-off on showing it universally.

Neither is a blocker — Phase 1 is safe on its own and doesn't touch the inline edit behavior.

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


2 months ago

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


5 weeks ago

#24 @joedolson
4 weeks ago

I took a look at the PR, and I'm not sure this is a viable direction to go as it is. It does make the accessibility mode available without a separate mode, but it is such a visible interface that it's likely to drive other users to engage with it, and I think that will actually cause a great deal of confusion. For many users, they will likely have never seen these interfaces, and will not understand why they are there.

This is on me; I underestimated how much of an impact it would make for those links to be always visible.

I think what might make it more feasible is to make those links into focusable screen-reader-text links, instead. That means that their primary targets remain users who need them - screen reader and keyboard users, but they aren't broadly exposed to the majority of users.

In that case, it may be a more feasible phase 1, with a truly minimal impact.

#25 @sanket.parmar
4 weeks ago

Thanks @joedolson, focusable screen-reader-text links make sense. Since keyboard users are a target too, the link needs to become visible on focus (WCAG 2.4.7), so the proposal is to show it just left of the toggle arrow, styled like the existing Accessibility Mode link; does that look work for you? The class swap would happen in the admin-widgets script rather than in wp_widget_control(), so no-JS users keep the visible link and the Customizer, which renders the same markup, is unaffected.

This ticket was mentioned in ​PR #14230 on ​WordPress/wordpress-develop by ​@sanket.parmar.


4 weeks ago
#26

On the classic Widgets screen, each widget's Edit/Add link to the single-widget screen becomes a screen-reader-text link that appears beside the toggle on keyboard focus, so keyboard and screen reader users can choose sidebar and position without Accessibility Mode. No-JS, Accessibility Mode and the Customizer are unchanged, and the link's URL is refreshed on focus so widgets added or moved without a reload point to the right place.

  • [x] npm run test:e2e -- tests/e2e/specs/widgets-classic.test.js (installs and activates Classic Widgets)
  • [x] Keyboard: tabbing past a widget's toggle shows Edit/Add to its left with a focus ring; Enter opens the single-widget screen
  • [x] Accessibility Mode, JavaScript disabled and Customizer: unchanged
  • [x] RTL
  • [ ] Screen reader: link announced as "Edit {widget}" / "Add {widget}"

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Drafting the patch and e2e test, and browser checks; reviewed and tested by me.

#27 @sanket.parmar
4 weeks ago

​https://github.com/WordPress/wordpress-develop/pull/14230 follows comment:24: the Edit/Add links are screen-reader-text and appear left of the toggle on keyboard focus, with no change for no-JS, Accessibility Mode or the Customizer.

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


4 weeks ago

#29 @joedolson
4 weeks ago

  • Type enhancement → task (blessed)

Since this is ultimately going to be handled in multiple phases, I'm changing this ticket to a task, and will add related tickets for the individual phases. This will also make completing this more flexible, as some parts of the overall task are enhancements, and others are bug fixes.

@rejaulalomkhan
4 weeks ago

PR 14230 testing: trunk, Search widget after tabbing past its toggle (no link)

@rejaulalomkhan
4 weeks ago

PR 14230 testing: Edit link visible on keyboard focus

@rejaulalomkhan
4 weeks ago

PR 14230 testing: Add link in Available Widgets on keyboard focus

​@rejaulalomkhan commented on ​PR #14230:


4 weeks ago
#30

Thanks for turning comment:24 around so quickly, @sanketio! Keeping the links as screen-reader-text and refreshing the URL on focus is a neat way to keep them correct after drag and drop. I tested it locally:

Patch Testing Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/14230 (head 30815d8)

Environment

  • WordPress: 7.2-alpha-63166-src
  • PHP: 8.3.35
  • Server: wordpress-develop local Docker environment (nginx)
  • Database: MySQL 9.7.2
  • Browser: Microsoft Edge (headless, via Playwright)
  • OS: Windows 11
  • Theme: Twenty Twenty-One 2.9
  • MU Plugins:
    • A one-line plugin returning false from use_widgets_block_editor, for the classic Widgets screen
  • Plugins: None activated

Steps taken

  1. Added a Search and a Pages widget to the sidebar and opened Appearance > Widgets with SCRIPT_DEBUG.
  2. On trunk, the Edit link has hide-if-js; pressing Tab from the Search widget's toggle moves focus to the next widget's toggle.
  3. With the PR, Tab from the toggle moves to the Search widget's Edit link, which appears left of the toggle with a focus ring (screenshot). In the Available Widgets list, the Add link behaves the same.
  4. Checked the accessibility tree: the links are named "Edit Search" and "Add Archives", so the hidden "Add"/"Edit" span isn't announced.
  5. Moved the Search widget below Pages in the DOM, as sorting does, and focused its link: the URL changed from key=0 to key=1.
  6. ✅ Patch is solving the problem: keyboard users reach the single-widget screen from the standard Widgets screen, and the link stays hidden for mouse users.

Expected result

  • The Edit/Add links are reachable and visible on keyboard focus, not visible otherwise, and point to the widget's current sidebar and position.

Additional Notes

  • Focus order: the link shows up to the left of the toggle, but comes after it in the tab order (sidebar header → toggle → Edit). This may be fine since it only appears on focus, but placing it before the toggle in the DOM would make the visual and focus order match.
  • I didn't run the e2e spec, a screen reader, or RTL.
  • AI assistance: Claude Code (Claude Opus 5.5) was used to run the browser checks and take the screenshots; I reviewed the results.

Screenshots/Screencast with results

  • Before (trunk), Search widget after tabbing past its toggle: https://core.trac.wordpress.org/raw-attachment/ticket/52399/pr14230-trunk-tab.png
  • After (PR), Edit link on focus: https://core.trac.wordpress.org/raw-attachment/ticket/52399/pr14230-edit-focus.png
  • After (PR), Add link in Available Widgets on focus: https://core.trac.wordpress.org/raw-attachment/ticket/52399/pr14230-add-focus.png

#31 @joedolson
4 weeks ago

  • Milestone 7.2 → 7.3

Thanks for your work on this! Due to the short amount of remaining time for enhancements, I'm punting this to 7.3.

Note: See TracTickets for help on using tickets.