Product Gallery: reset main image when variations are cleared (#42830)
* Product Gallery: reset main image when variations are cleared * Add changelog for woo core * Update event name to be more descriptive
This commit is contained in:
parent
1bf35ac737
commit
d15bfd2398
|
@ -109,8 +109,24 @@ const productGallery = {
|
|||
attributes: true,
|
||||
} );
|
||||
|
||||
const clearVariationsLink = document.querySelector(
|
||||
'.wp-block-add-to-cart-form .reset_variations'
|
||||
);
|
||||
|
||||
const selectFirstImage = () => {
|
||||
context.selectedImage = context.firstMainImageId;
|
||||
};
|
||||
|
||||
if ( clearVariationsLink ) {
|
||||
clearVariationsLink.addEventListener(
|
||||
'click',
|
||||
selectFirstImage
|
||||
);
|
||||
}
|
||||
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
document.removeEventListener( 'click', selectFirstImage );
|
||||
};
|
||||
},
|
||||
keyboardAccess: () => {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
Comment: Reset main image when variations are cleared.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
Comment: Reset main image when variations are cleared.
|
||||
|
Loading…
Reference in New Issue