WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 12 days ago

#52157 closed defect (bug) (maybelater)

Sidebar widget not partial refreshing for first widget add and remove

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

Description

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: https://a.cl.ly/WnulD9r6

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.


5 months ago

#2 @noisysocks
5 months 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
12 days 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.