From 335a38262a0d579a97fb2df36ca54d05415fe839 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 5 Sep 2025 20:43:21 +0800 Subject: [PATCH] fix(media): enhance click handling and cursor styles in social media media components - Updated the `PreviewMediaContent` and `SocialMediaGallery` components to improve click handling by stopping event propagation. - Added cursor styles to indicate zoom functionality for better user experience. These changes enhance the interactivity and visual feedback of media elements in the application. --- .../src/components/ui/media/PreviewMediaContent.tsx | 10 +++------- .../modules/entry-column/Items/social-media-item.tsx | 10 ++++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/desktop/layer/renderer/src/components/ui/media/PreviewMediaContent.tsx b/apps/desktop/layer/renderer/src/components/ui/media/PreviewMediaContent.tsx index b829d4eab..57596b228 100644 --- a/apps/desktop/layer/renderer/src/components/ui/media/PreviewMediaContent.tsx +++ b/apps/desktop/layer/renderer/src/components/ui/media/PreviewMediaContent.tsx @@ -569,12 +569,8 @@ const DOMImageViewer: FC<{ smooth={true} onInit={(e) => { if (e.instance.wrapperComponent) { - e.instance.wrapperComponent.onclick = (e) => { - if (e.target instanceof HTMLDivElement && e.target.dataset.imageContainer) { - e.stopPropagation() - } else { - dismiss() - } + e.instance.wrapperComponent.onclick = () => { + dismiss() } } }} @@ -593,7 +589,7 @@ const DOMImageViewer: FC<{ wrapperProps={{ onClick: stopPropagation, }} - wrapperClass="!w-full !h-full !absolute !inset-0" + wrapperClass="!w-full !h-full !absolute !inset-0 cursor-zoom-out" contentClass="!w-full !h-full flex items-center justify-center" >
{ type={media.type} previewImageUrl={media.preview_image_url} blurhash={media.blurhash} - className="data-[state=loading]:!bg-material-ultra-thick size-28 shrink-0" + className="data-[state=loading]:!bg-material-ultra-thick size-28 shrink-0 cursor-zoom-in" loading="lazy" proxy={proxySize} - onClick={() => { + onClick={(e) => { + e.stopPropagation() previewMedia( mediaList.map((m) => ({ url: m.url, @@ -334,10 +335,11 @@ export const SocialMediaGallery = ({ entryId }: { entryId: string }) => { type={m.type} previewImageUrl={m.preview_image_url} blurhash={m.blurhash} - className="aspect-square w-full rounded object-cover" + className="aspect-square w-full cursor-zoom-in rounded object-cover" loading="lazy" proxy={proxySize} - onClick={() => { + onClick={(e) => { + e.stopPropagation() previewMedia( media.map((m) => ({ url: m.url,