Always bring modified item to front in canvas

This commit is contained in:
Josh Perez 2021-12-07 10:56:02 -05:00 committed by GitHub
parent e8a2d1f2c9
commit 93310de194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -531,10 +531,6 @@ export const MediaEditor = ({
return;
}
if (editMode !== EditMode.Text) {
return;
}
const obj = fabricCanvas.getActiveObject();
if (!obj || !(obj instanceof MediaEditorFabricIText)) {
@ -544,7 +540,7 @@ export const MediaEditor = ({
obj.exitEditing();
obj.set(getTextStyleAttributes(textStyle, sliderValue));
fabricCanvas.requestRenderAll();
}, [editMode, fabricCanvas, sliderValue, textStyle]);
}, [fabricCanvas, sliderValue, textStyle]);
// Create the CroppingRect
useEffect(() => {
@ -601,6 +597,7 @@ export const MediaEditor = ({
setCanCrop(false);
}, [editMode, fabricCanvas, imageState.height, imageState.width, zoom]);
// Create an IText node when edit mode changes to Text
useEffect(() => {
if (!fabricCanvas) {
return;

View File

@ -15,6 +15,8 @@ export class MediaEditorFabricIText extends fabric.IText {
textAlign: 'center',
...options,
});
this.on('modified', () => this.canvas?.bringToFront(this));
}
static override fromObject(

View File

@ -19,6 +19,8 @@ export class MediaEditorFabricSticker extends fabric.Image {
}
super(normalizedElement, options);
this.on('modified', () => this.canvas?.bringToFront(this));
}
static fromObject(