Skip to content

Commit 701ed71

Browse files
committed
fix: image gallery toggle button should stay in place when toggling gallery
1 parent cac9ac1 commit 701ed71

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ function RemoteFunctions(config = {}) {
305305
startEditing(element);
306306
}else if(LivePreviewView.getNodeMoreOptionsHandler(action)) {
307307
const handler = LivePreviewView.getNodeMoreOptionsHandler(action);
308-
return handler && handler.handleClick && handler.handleClick(e, element);
308+
return handler && handler.handleClick &&
309+
handler.handleClick(e, element, _nodeMoreOptionsBox && _nodeMoreOptionsBox._shadow);
309310
}
310311
}
311312

src/extensionsIntegrated/phoenix-pro/browser-context/image-gallery.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

12401254
function 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

Comments
 (0)