FIX: Make bindMobileUploadButton explicit for upload mixins (#14220)

When using ComposerUpload and/or ComposerUploadUppy, we were
always calling bindMobileUploadButton. However with more composer-like
interfaces being developed, we need this to be optional, as not
everywhere will have a separate mobile upload button to bind to.

Also makes it so the composer extending the ComposerUpload mixins is
responsible for explicitly unbinding the mobile upload button if
it needs to.
This commit is contained in:
Martin Brennan 2021-09-02 17:31:15 +10:00 committed by GitHub
parent 6e812f30ec
commit fa66d1fa82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -219,6 +219,8 @@ export default Component.extend(ComposerUpload, {
}
this._bindUploadTarget();
this._bindMobileUploadButton();
this.appEvents.trigger("composer:will-open");
},
@ -607,6 +609,7 @@ export default Component.extend(ComposerUpload, {
@on("willDestroyElement")
_composerClosed() {
this._unbindMobileUploadButton();
this.appEvents.trigger("composer:will-close");
next(() => {
// need to wait a bit for the "slide down" transition of the composer

View File

@ -46,11 +46,6 @@ export default Mixin.create({
@on("willDestroyElement")
_unbindUploadTarget() {
this.mobileUploadButton?.removeEventListener(
"click",
this.mobileUploadButtonEventListener
);
this.fileInputEl?.removeEventListener(
"change",
this.fileInputEventListener
@ -86,7 +81,6 @@ export default Mixin.create({
this._unbindUploadTarget();
this._bindFileInputChangeListener();
this._bindPasteListener();
this._bindMobileUploadButton();
this._uppyInstance = new Uppy({
id: this.uppyId,

View File

@ -327,8 +327,6 @@ export default Mixin.create({
}
});
});
this._bindMobileUploadButton();
},
_bindMobileUploadButton() {
@ -345,13 +343,15 @@ export default Mixin.create({
}
},
@on("willDestroyElement")
_unbindUploadTarget() {
_unbindMobileUploadButton() {
this.mobileUploadButton?.removeEventListener(
"click",
this.mobileUploadButtonEventListener
);
},
@on("willDestroyElement")
_unbindUploadTarget() {
this._validUploads = 0;
const $uploadTarget = $(this.element);
try {