Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uppy.close() crashes when remote-sources or image-editor is installed #3914

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/@uppy/dashboard/src/components/FileCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class FileCard extends Component {
}

handleCancel = () => {
const { currentImage } = this.getPluginState()
const file = this.props.uppy.getFile(currentImage.id)
const file = this.props.files[this.props.fileCardFor]
this.props.uppy.emit('file-editor:cancel', file)
this.props.toggleFileCard(false)
}
Expand Down
6 changes: 4 additions & 2 deletions packages/@uppy/image-editor/src/ImageEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ export default class ImageEditor extends UIPlugin {

uninstall () {
const { currentImage } = this.getPluginState()
const file = this.uppy.getFile(currentImage.id)
this.uppy.emit('file-editor:cancel', file)

if (currentImage) {
const file = this.uppy.getFile(currentImage.id)
this.uppy.emit('file-editor:cancel', file)
}
this.unmount()
}

Expand Down
4 changes: 3 additions & 1 deletion packages/@uppy/remote-sources/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export default class RemoteSources extends BasePlugin {
throw new Error(`Invalid plugin: "${pluginId}" is not one of: ${formatter.format(pluginNames)}.`)
}
this.uppy.use(plugin, optsForRemoteSourcePlugin)
this.#installedPlugins.add(plugin)
// `plugin` is a class, but we want to track the instance object
// so we have to do `getPlugin` here.
this.#installedPlugins.add(this.uppy.getPlugin(pluginId))
})
}

Expand Down