Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#52157 closed defect (bug) (maybelater)

Sidebar widget not partial refreshing for first widget add and remove

Reported by: rohitrpatil's profile rohitrpatil Owned by:
Milestone: Priority: normal
Severity: major Version: 5.6
Component: Customize Keywords: 2nd-opinion
Focuses: ui, performance Cc:


When you add the first widget in the sidebar it's a refreshing customizer completely and not partial refreshing.

  1. Go to Customizer
  2. Go to the Widgets panel.
  3. Remove all the widgets one by one.
  4. At the last widget when you remove it, it refreshes the customizer.
  5. When adding the first widget it again refreshes the customizer.

First onward, it partially refreshing the customizer as expected.

Please find the attached video for further reference:

I need to programmatically add the widget to the dynamic sidebar but as it is refreshing the customizer when adding the first widget to the sidebar I can not proceed with my custom CSS logic.

Please check and let me know if you need anything else.

Change History (3)

This ticket was mentioned in Slack in #core by lukecarbis. View the logs.

4 years ago

#2 @noisysocks
4 years ago

  • Component changed from Widgets to Customize
  • Keywords 2nd-opinion added; needs-partial-refresh needs-patch removed

This is probably because the theme (Twenty Twenty-one) will not display the container that widgets appear in when there are zero widgets. Partial refresh requires that container to exist in order to work and so it falls back to a full refresh.

I don't think there's anything we can do here. Partial refresh is only designed to be best effort and we definitely want to encourage themes to not render empty containers.

Adding 2nd-opinion to double check my thinking here.

#3 @celloexpressions
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

I concur with the assessment in 2. By default, adding the first widget to a sidebar triggers a full refresh for the theme to recognize that the sidebar becomes active. Themes (or plugins, which can also register widget areas) could theoretically hook into the core API to prevent that behavior and dynamically instantiate the widget area container markup.

Core could potentially change this in the future if there were substantial demand for a core API that helped themes avoid the initial refresh. This seems unlikely to offer a major user benefit since themes would need to opt in.

Note: See TracTickets for help on using tickets.