Skip to content

Widgets: Keep the widget Edit/Add text link visible when JavaScript is available#12686

Open
irozum wants to merge 3 commits into
WordPress:trunkfrom
irozum:enhancement/52399-widget-accessibility-mode-phase-1
Open

Widgets: Keep the widget Edit/Add text link visible when JavaScript is available#12686
irozum wants to merge 3 commits into
WordPress:trunkfrom
irozum:enhancement/52399-widget-accessibility-mode-phase-1

Conversation

@irozum

@irozum irozum commented Jul 24, 2026

Copy link
Copy Markdown

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.

The problem: 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 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.

The fix:

  • Removed hide-if-js from the link in wp_widget_control(), so it stays visible alongside the toggle button.
  • Removing that class alone caused a layout regression: the link stacked below the toggle button instead of sitting beside it, since both are children of the floated .widget-title-action container and the link's display: block forced a line break. Added a small CSS rule scoping the link to display: inline-block when rendered next to the toggle button.
  • Accessibility Mode's existing higher-specificity override (.widgets_access #wpwrap .widget-control-edit { display: block; }) is unaffected, since that mode hides the toggle button entirely.

Verification:

  • Manually tested in the browser with the Classic Widgets plugin active, in both standard mode and Accessibility Mode.
  • Existing and new PHPUnit coverage added in tests/phpunit/tests/widgets.php.

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

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.


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.

Copilot AI review requested due to automatic review settings July 24, 2026 17:35
@github-actions

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 irozum.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Keeps the classic Widgets screen’s plain-text widget “Edit/Add” link visible even when JavaScript is enabled, preserving an always-available path to the accessible single-widget edit screen.

Changes:

  • Remove hide-if-js from the .widget-control-edit link markup in wp_widget_control().
  • Add a CSS override to keep the link aligned beside the JS toggle (instead of stacking below it).
  • Add/refactor PHPUnit coverage for wp_widget_control(), including a regression test for the edit link visibility.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/wp-admin/includes/widgets.php Makes the widget edit/add text link visible when JS is available by removing hide-if-js.
src/wp-admin/css/widgets.css Ensures .widget-control-edit sits inline next to the toggle inside .widget-title-action.
tests/phpunit/tests/widgets.php Refactors widget-control rendering into a helper and adds regression coverage for the edit link class.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +832 to +833
$this->assertStringContainsString( 'class="widget-control-edit"', $control, 'The Edit/Add text link should remain visible when JavaScript is available, as a plain-text path to the accessible single-widget edit screen.' );
$this->assertStringNotContainsString( 'widget-control-edit hide-if-js', $control );
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