From d6b7c2c6141039dfd4adcfa77ced27471bc0c214 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Thu, 12 Oct 2023 13:17:27 +0200 Subject: [PATCH] Fix #1114 gallery: keep current item if possible when updating items --- packages/gallery-plugin/src/GalleryPlugin.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/gallery-plugin/src/GalleryPlugin.ts b/packages/gallery-plugin/src/GalleryPlugin.ts index f7fc24006..f1c3977b8 100644 --- a/packages/gallery-plugin/src/GalleryPlugin.ts +++ b/packages/gallery-plugin/src/GalleryPlugin.ts @@ -91,7 +91,7 @@ export class GalleryPlugin extends AbstractConfigurablePlugin< if (e instanceof events.PanoramaLoadedEvent) { const item = this.items.find((i) => utils.deepEqual(i.panorama, e.data.panorama)); this.currentId = item?.id; - this.gallery.setActive(item?.id); + this.gallery.setActive(this.currentId); } else if (e instanceof events.ShowPanelEvent) { this.gallery.isVisible() && this.hide(); } @@ -152,6 +152,12 @@ export class GalleryPlugin extends AbstractConfigurablePlugin< this.gallery.setItems(this.items); + if (this.currentId) { + const item = this.items.find((i) => i.id === this.currentId); + this.currentId = item?.id; + this.gallery.setActive(this.currentId); + } + this.__updateButton(); }