Skip to content

Widgets: Reveal widget edit links on keyboard focus - #14230

Open
sanketio wants to merge 1 commit into
WordPress:trunkfrom
sanketio:fix/52399
Open

sanketio wants to merge 1 commit into
WordPress:trunkfrom
sanketio:fix/52399

Conversation

@sanketio

Copy link
Copy Markdown

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.

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

Trac ticket: https://core.trac.wordpress.org/ticket/52399

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.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sanketparmar, rejaulalomkhan.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@rejaulalomkhan

rejaulalomkhan commented Oct 14, 2026 •

Copy link
Copy Markdown

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: #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

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.

2 participants