This commit is contained in:
alexh-humanitix 2026-07-14 18:27:58 +03:00 committed by GitHub
commit 92d151f5cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
"@uppy/image-editor": patch
---
Fix cropper not reinitializing after save/cancel by destroying previous instance in `start()` and cleaning up on file removal

View file

@ -350,6 +350,7 @@ export default class ImageEditor<
*/
start = (file: UppyFile<M, B>): void => {
// Clean up any previous editing session
this.destroyCropper()
if (this.objectUrl) {
URL.revokeObjectURL(this.objectUrl)
this.objectUrl = null
@ -480,8 +481,16 @@ export default class ImageEditor<
return this.objectUrl
}
handleFileRemoved = (file: UppyFile<M, B>): void => {
const { currentImage } = this.getPluginState()
if (currentImage && currentImage.id === file.id) {
this.stop()
}
}
install(): void {
this.resetEditorState(null)
this.uppy.on('file-removed', this.handleFileRemoved)
const { target } = this.opts
if (target) {
@ -496,6 +505,7 @@ export default class ImageEditor<
const file = this.uppy.getFile(currentImage.id)
this.uppy.emit('file-editor:cancel', file)
}
this.uppy.off('file-removed', this.handleFileRemoved)
this.stop()
this.unmount()
}