Skip to content

Build your personal knowledge base with Trilium Notes

client/image viewer: fix some issues

Adorian Doran31131385c13a
diff --git a/apps/client/src/widgets/react/ImageViewer.tsx b/apps/client/src/widgets/react/ImageViewer.tsx
index 538395ea15..128be79aef 100644
--- a/apps/client/src/widgets/react/ImageViewer.tsx
+++ b/apps/client/src/widgets/react/ImageViewer.tsx
@@ -58,9 +58,9 @@ export default function ImageViewer({ src, imgClassName, alt = "", minScale = 0.
autoAlignment={{ disabled: true }}
doubleClick={{ mode: "reset" }}
onTransform={(_ref, { scale }) => {
- const { pannable, largeZoom } = evaluateImageZoom(scale, imgRef.current);
- setPannable(pannable);
- setLargeZoom(largeZoom);
+ const { pannable: nextPannable, largeZoom: nextLargeZoom } = evaluateImageZoom(scale, imgRef.current);
+ if (nextPannable !== pannable) setPannable(nextPannable);
+ if (nextLargeZoom !== largeZoom) setLargeZoom(nextLargeZoom);
}}
onPanningStart={() => setPanning(true)}
onPanningStop={() => setPanning(false)}
diff --git a/apps/client/src/widgets/type_widgets/Attachment.tsx b/apps/client/src/widgets/type_widgets/Attachment.tsx
index 91a0780640..9d38d8d9cb 100644
--- a/apps/client/src/widgets/type_widgets/Attachment.tsx
+++ b/apps/client/src/widgets/type_widgets/Attachment.tsx
@@ -239,7 +239,7 @@ function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment,
{textContent && <TextPreview content={textContent} />}
{isZoomableImage ? (
<div key="image-viewer" ref={imageViewerWrapper} className="attachment-content-wrapper attachment-image-viewer">
- <ImageViewer key={attachment.utcDateModified} src={imageSrc} alt={attachment.title} />
+ <ImageViewer key={`${attachment.attachmentId}-${attachment.utcDateModified}`} src={imageSrc} alt={attachment.title} />
</div>
) : (
<div key="rendered" ref={contentWrapper} className="attachment-content-wrapper" />