🐛 Isolate preview changes to relevant sections

Before this, any style change updated all preview buttons on the current page. Now, most changes are limited to the current section.

For exaple, changing the height of “Mini Cart Buttons” only updates the mini cart button preview, and no other preview sections.
This commit is contained in:
Philipp Stracker 2024-07-15 13:58:58 +02:00
parent 07ec924c77
commit a4a4f80a99
No known key found for this signature in database

View file

@ -283,6 +283,17 @@ class PreviewButtonManager {
*/
_configureAllButtons( ppcpConfig ) {
Object.entries( this.buttons ).forEach( ( [ id, button ] ) => {
const limitWrapper = ppcpConfig.button?.wrapper;
/**
* When the ppcpConfig object specifies a button wrapper, then ensure to limit preview
* changes to this individual wrapper. If no button wrapper is defined, the
* configuration is relevant for all buttons on the page.
*/
if ( limitWrapper && button.wrapper !== limitWrapper ) {
return;
}
this._configureButton( id, {
...ppcpConfig,
button: {