WordPress.org

Make WordPress Core

Opened 20 months ago

Last modified 20 months ago

#43386 new enhancement

render-partials-init similar to render-partials-response in customiser selective refresh.

Reported by: gandham Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.5
Component: Customize Keywords:
Focuses: ui, javascript, administration Cc:
PR Number:

Description

These are the events that are triggered when a selective refresh takes place.

render-partials-response
partial-content-rendered
partial-placement-moved
widget-updated
sidebar-updated

But there is no event to identify the start of the partial request. This is required if we want to make some changes (like display a loader) to the UI while the request in progress.

.customize-partial-refreshing class is added while the partial refresh is in progress, but a javascript event will be handy.
Use case: Partial used to update a style tag in the head.

adding the following event after initiating the request in
wp-includes/js/customize-selective-refresh.js at line 773 works, but not sure if it the right way.

self.trigger( 'render-partials-init', data );

Change History (3)

#1 @gandham
20 months ago

I think we can override the preparePlacement method and do the UI changes there, but still if we can fire an event in the prepare placement method it would be useful.

/**
		 * Prepare container for selective refresh.
		 *
		 * @since 4.5.0
		 *
		 * @param {Placement} placement
		 */
		preparePlacement: function( placement ) {
			$( placement.container ).addClass( 'customize-partial-refreshing' );
			self.trigger( 'partial-content-initiated', placement );
		},

#2 @westonruter
20 months ago

  • Version changed from 4.9.4 to 4.5

Yes, I think in general it is better to extend the Partial class to override the preparePlacement method in JS to achieve this.

#3 @westonruter
20 months ago

  • Component changed from General to Customize
Note: See TracTickets for help on using tickets.