@@ -40,8 +40,9 @@ function scrollImageToViewportIfRequired(element, imageGalleryElement) {
4040 * it shows the image ribbon gallery at the bottom of the live preview
4141 * @param {Event } event
4242 * @param {DOMElement } element - the HTML DOM element that was clicked (should be an image)
43+ * @param {DOMElement } toolBoxShadow - the HTML DOM element that was clicked (should be an image)
4344 */
44- function handleImageGalleryOptionClick ( event , element ) {
45+ function handleImageGalleryOptionClick ( event , element , toolBoxShadow ) {
4546 dismissImageRibbonGallery ( ) ;
4647
4748 if ( imageGallerySelected ) {
@@ -53,6 +54,19 @@ function handleImageGalleryOptionClick(event, element) {
5354 }
5455
5556 handleImageGalleryStateChange ( ) ;
57+ event . preventDefault ( ) ;
58+ event . stopPropagation ( ) ;
59+ if ( ! toolBoxShadow || ! toolBoxShadow . querySelector ( ".img-gallery-toggle" ) ) {
60+ console . warn ( "No toolbox shadow div found to update image gallery state" ) ;
61+ return true ;
62+ }
63+ const imgGalleryIcon = toolBoxShadow . querySelector ( ".img-gallery-toggle" ) ;
64+ if ( imageGallerySelected ) {
65+ imgGalleryIcon . classList . add ( "selected" ) ;
66+ } else {
67+ imgGalleryIcon . classList . remove ( "selected" ) ;
68+ }
69+ return true ;
5670}
5771
5872/**
@@ -1239,7 +1253,7 @@ function handleDownloadEvent(eventType, data) {
12391253
12401254function renderImageGalleryIcon ( element , shadow ) {
12411255 if ( element && element . tagName . toLowerCase ( ) === 'img' ) {
1242- const selectedClass = imageGallerySelected ? 'class="selected"' : "" ;
1256+ const selectedClass = imageGallerySelected ? 'class="img-gallery-toggle selected"' : "img-gallery-toggle " ;
12431257
12441258 return {
12451259 listOrder : proConstants . TOOLBOX_ORDERING . IMAGE_GALLERY ,
0 commit comments