Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'trunk' into fix/order-endpoint-tax-format-incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
hsingyuc authored Nov 16, 2023
2 parents c1f34ea + 2ec01df commit c343f47
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 13 additions & 1 deletion assets/js/blocks/product-gallery/frontend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface State {
export interface ProductGalleryInteractivityApiContext {
woocommerce: {
selectedImage: string;
firstMainImageId: string;
imageId: string;
visibleImagesIds: string[];
dialogVisibleImagesIds: string[];
Expand Down Expand Up @@ -40,6 +41,11 @@ interface Actions {
handleNextImageButtonClick: {
( store: Store ): void;
};
dialog: {
handleCloseButtonClick: {
( store: Store ): void;
};
};
};
}

Expand Down Expand Up @@ -123,7 +129,9 @@ interactivityApiStore( {

// Check if the esc key is pressed.
if ( event.keyCode === Keys.ESC ) {
context.woocommerce.isDialogOpen = false;
actions.woocommerce.dialog.handleCloseButtonClick(
store
);
}

// Check if left arrow key is pressed.
Expand Down Expand Up @@ -175,6 +183,10 @@ interactivityApiStore( {
dialog: {
handleCloseButtonClick: ( { context }: Store ) => {
context.woocommerce.isDialogOpen = false;

// Reset the main image.
context.woocommerce.selectedImage =
context.woocommerce.firstMainImageId;
},
},
handleSelectImage: ( { context }: Store ) => {
Expand Down
1 change: 1 addition & 0 deletions src/BlockTypes/ProductGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ protected function render( $attributes, $content, $block ) {
array(
'woocommerce' => array(
'selectedImage' => $product->get_image_id(),
'firstMainImageId' => $product->get_image_id(),
'visibleImagesIds' => ProductGalleryUtils::get_product_gallery_image_ids( $product, $number_of_thumbnails, true ),
'dialogVisibleImagesIds' => ProductGalleryUtils::get_product_gallery_image_ids( $product, null, false ),
'mouseIsOverPreviousOrNextButton' => false,
Expand Down
6 changes: 4 additions & 2 deletions templates/parts/product-gallery.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group">
<!-- wp:woocommerce/product-gallery {"mode":"full"} -->
<!-- wp:post-title {"align":"full","__woocommerceNamespace":"woocommerce/product-collection/product-title"} /-->

<!-- wp:woocommerce/product-gallery {"mode":"full","pagerDisplayMode":"off","align":"wide"} -->
<div
class="wp-block-woocommerce-product-gallery wc-block-product-gallery wc-block-product-gallery--has-next-previous-buttons-inside-image">
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
Expand All @@ -24,4 +26,4 @@
</div>
<!-- /wp:woocommerce/product-gallery -->
</div>
<!-- /wp:group -->
<!-- /wp:group -->

0 comments on commit c343f47

Please sign in to comment.