diff --git a/ts/components/MediaEditor.tsx b/ts/components/MediaEditor.tsx index 8d18f387fb..99a78c9a12 100644 --- a/ts/components/MediaEditor.tsx +++ b/ts/components/MediaEditor.tsx @@ -399,6 +399,7 @@ export const MediaEditor = ({ const [canRedo, setCanRedo] = useState(false); const [canUndo, setCanUndo] = useState(false); + const [canCrop, setCanCrop] = useState(false); const [cropAspectRatioLock, setcropAspectRatioLock] = useState(false); const [drawTool, setDrawTool] = useState(DrawTool.Pen); const [drawWidth, setDrawWidth] = useState(DrawWidth.Regular); @@ -572,6 +573,13 @@ export const MediaEditor = ({ width, }); + rect.on('modified', () => { + const { height: currHeight, width: currWidth } = + rect.getBoundingRect(true); + + setCanCrop(currHeight < height || currWidth < width); + }); + rect.on('deselected', () => { setEditMode(undefined); }); @@ -589,6 +597,8 @@ export const MediaEditor = ({ } }); } + + setCanCrop(false); }, [editMode, fabricCanvas, imageState.height, imageState.width, zoom]); useEffect(() => { @@ -857,6 +867,7 @@ export const MediaEditor = ({