Keep a tall logo inside the crop dialog

react-image-crop's stylesheet gives the image max-height: inherit, so the
limit set on the image was overridden: a portrait logo ran past the
dialog and its bottom handles could not be reached. The limit now sits on
the crop wrapper, and the scrolling container is gone.
This commit is contained in:
ignacionelson
2026-10-03 12:10:42 -03:00
parent bbd424a8d1
commit 2d8562abba
@@ -108,15 +108,20 @@ export default function LogoCropDialog({ open, onOpenChange, sourceUrl, savedCro
</DialogDescription>
</DialogHeader>
<div className="bg-muted/40 flex max-h-[60vh] justify-center overflow-auto rounded border p-2">
<ReactCrop crop={crop} onChange={(_, percent) => setCrop(percent)} keepSelection minWidth={8} minHeight={8}>
<img
src={sourceUrl}
alt=""
onLoad={(e) => onImageLoad(e.currentTarget)}
style={{ imageOrientation: 'none' }}
className="max-h-[56vh] max-w-full"
/>
<div className="bg-muted/40 flex justify-center rounded border p-2">
{/* The height limit goes on the crop wrapper: the library's
stylesheet gives the image `max-height: inherit`, so a
limit on the image itself is overridden, and a tall logo
would push the bottom handles out of reach. */}
<ReactCrop
crop={crop}
onChange={(_, percent) => setCrop(percent)}
keepSelection
minWidth={8}
minHeight={8}
style={{ maxHeight: '56vh' }}
>
<img src={sourceUrl} alt="" onLoad={(e) => onImageLoad(e.currentTarget)} style={{ imageOrientation: 'none' }} />
</ReactCrop>
</div>