mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-17 16:50:22 +00:00
Merge fe290e3001 into 0b1f79c90d
This commit is contained in:
commit
92d151f5cb
2 changed files with 15 additions and 0 deletions
5
.changeset/fix-image-editor-cleanup.md
Normal file
5
.changeset/fix-image-editor-cleanup.md
Normal 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
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue