Make WordPress Core

Opened 6 days ago

Closed 19 hours ago

#50508 closed defect (bug) (fixed)

Customize: Widgets appear "inactive" by default

Reported by: afercia Owned by: SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: trunk
Component: Customize Keywords: has-screenshots has-patch
Focuses: javascript Cc:


This appear to be a regression in trunk. I was able to reproduce on two different machines.

  • latest trunk
  • no plugins active, Twenty Twenty theme
  • make sure there are some Widgets added in the theme's widget areas
  • go to the Customizer > Widgets > one of the widget areas e.g. the Twenty Twenty "Footer 1"
  • observe all the Widgets listed in the left sidebar look "inactive" their container gets a CSS opacity: 0.5
  • observe it happens also in "reorder mode"
  • all widget boxes are fully functional, they just appear "inactive" because of the opacity - they also have an insufficient color contrast
  • compare with latest WordPress stable, where the listed widgets don't get the opacity
  • to my understanding, the opacity should only be set on the widgets that are _not_ rendered
  • something wrong appears to happen with the widget-rendered class, which isn't applied

See attached screenshot, from left to right:

  • trunk: widgets list normal mode
  • trunk: widgets list "reorder" mode
  • 5.4: widgets list normal mode

Attachments (4)

50508.png (181.4 KB) - added by afercia 6 days ago.
50508.diff (546 bytes) - added by dlh 22 hours ago.
50508.2.diff (2.3 KB) - added by SergeyBiryukov 21 hours ago.
50508.3.diff (2.6 KB) - added by dlh 20 hours ago.

Download all attachments as: .zip

Change History (9)

6 days ago

This ticket was mentioned in Slack in #themereview by joyously. View the logs.

6 days ago

22 hours ago

#2 follow-up: @dlh
22 hours ago

  • Keywords has-patch added

Introduced, I think, in [47550] with the change to a strict in_array() check in \WP_Customize_Widgets::is_widget_rendered().

The rendered_widgets property is an associative array of 'widget-id' => true, so the previous loose check was actually also incorrect — it loosely compared the widget ID to true. Since the widget ID is the key, a ! empty() should cover it.

@afercia would you mind testing 50508.diff?

#3 in reply to: ↑ 2 @SergeyBiryukov
21 hours ago

Replying to dlh:

would you mind testing 50508.diff?

Thanks for the patch! It appears to solve the immediate issue.

However, that still leaves an inconsistent structure of the rendered_sidebars and rendered_widgets properties:

array(5) {
  string(9) "sidebar-1"
  string(9) "sidebar-2"
  string(9) "sidebar-1"
  string(9) "sidebar-2"
  string(9) "sidebar-1"
array(7) {

I think that can still lead to regressions like this in the future.

50508.2.diff attempts to bring some consistency by using the same structure for rendered_sidebars. As a positive side effect, this also removes duplicate values:

array(2) {

Since the class is final and these properties are protected, I think there should be no backward compatibility concerns in changing the structure. Could you double check?

Last edited 20 hours ago by SergeyBiryukov (previous) (diff)

20 hours ago

#4 @dlh
20 hours ago

Makes sense to me. The only thing I noticed was that the logic to export renderedSidebars and renderedWidgets assumes that every item in the respective property is set to true, which is currently accurate in practice, but isn't guaranteed. 50508.3.diff filters out falsey values just in case.

#5 @SergeyBiryukov
19 hours ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48299:

Customize: Correct the check for rendered widgets in WP_Customize_Widgets::is_widget_rendered().

Make the structure of ::$rendered_sidebars and ::$rendered_widgets properties consistent.

This resolves an issue with every widget being marked as inactive by default on the Widgets panel.

Props dlh, afercia, SergeyBiryukov.
Fixes #50508.

Note: See TracTickets for help on using tickets.