From 988139c0636f11e6f0762fa5803730d2356932aa Mon Sep 17 00:00:00 2001 From: Dmitri Date: Mon, 27 Apr 2026 13:32:40 +0200 Subject: [PATCH] fixed back button positioning issue in gallery element --- frontend/src/pages/constructor.tsx | 36 ++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/constructor.tsx b/frontend/src/pages/constructor.tsx index a050fdc..8348f8c 100644 --- a/frontend/src/pages/constructor.tsx +++ b/frontend/src/pages/constructor.tsx @@ -876,6 +876,30 @@ const ConstructorPage = ({ mode = 'constructor' }: ConstructorPageProps) => { typeof item.galleryCarouselBackY === 'number' ? item.galleryCarouselBackY : undefined, + galleryCarouselPrevWidth: + typeof item.galleryCarouselPrevWidth === 'string' + ? item.galleryCarouselPrevWidth + : undefined, + galleryCarouselPrevHeight: + typeof item.galleryCarouselPrevHeight === 'string' + ? item.galleryCarouselPrevHeight + : undefined, + galleryCarouselNextWidth: + typeof item.galleryCarouselNextWidth === 'string' + ? item.galleryCarouselNextWidth + : undefined, + galleryCarouselNextHeight: + typeof item.galleryCarouselNextHeight === 'string' + ? item.galleryCarouselNextHeight + : undefined, + galleryCarouselBackWidth: + typeof item.galleryCarouselBackWidth === 'string' + ? item.galleryCarouselBackWidth + : undefined, + galleryCarouselBackHeight: + typeof item.galleryCarouselBackHeight === 'string' + ? item.galleryCarouselBackHeight + : undefined, tooltipTitle: typeof item.tooltipTitle === 'string' ? item.tooltipTitle : '', tooltipText: @@ -1184,7 +1208,15 @@ const ConstructorPage = ({ mode = 'constructor' }: ConstructorPageProps) => { ? { galleryCarouselNextX: x, galleryCarouselNextY: y } : { galleryCarouselBackX: x, galleryCarouselBackY: y }; - updateSelectedElement(positionPatch); + // Update the element by explicit ID (not by selection) + // because the gallery element may not be selected when the carousel is open + setElements((prev) => + prev.map((el) => + el.id === activeGalleryCarousel.element.id + ? { ...el, ...positionPatch } + : el, + ), + ); // Update the active carousel element to reflect the new positions setActiveGalleryCarousel((prev) => @@ -1193,7 +1225,7 @@ const ConstructorPage = ({ mode = 'constructor' }: ConstructorPageProps) => { : null, ); }, - [activeGalleryCarousel, updateSelectedElement], + [activeGalleryCarousel, setElements], ); // Handler for carousel element button position changes (constructor only)