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:
parent
6e812f30ec
commit
fa66d1fa82
|
@ -219,6 +219,8 @@ export default Component.extend(ComposerUpload, {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._bindUploadTarget();
|
this._bindUploadTarget();
|
||||||
|
this._bindMobileUploadButton();
|
||||||
|
|
||||||
this.appEvents.trigger("composer:will-open");
|
this.appEvents.trigger("composer:will-open");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -607,6 +609,7 @@ export default Component.extend(ComposerUpload, {
|
||||||
|
|
||||||
@on("willDestroyElement")
|
@on("willDestroyElement")
|
||||||
_composerClosed() {
|
_composerClosed() {
|
||||||
|
this._unbindMobileUploadButton();
|
||||||
this.appEvents.trigger("composer:will-close");
|
this.appEvents.trigger("composer:will-close");
|
||||||
next(() => {
|
next(() => {
|
||||||
// need to wait a bit for the "slide down" transition of the composer
|
// need to wait a bit for the "slide down" transition of the composer
|
||||||
|
|
|
@ -46,11 +46,6 @@ export default Mixin.create({
|
||||||
|
|
||||||
@on("willDestroyElement")
|
@on("willDestroyElement")
|
||||||
_unbindUploadTarget() {
|
_unbindUploadTarget() {
|
||||||
this.mobileUploadButton?.removeEventListener(
|
|
||||||
"click",
|
|
||||||
this.mobileUploadButtonEventListener
|
|
||||||
);
|
|
||||||
|
|
||||||
this.fileInputEl?.removeEventListener(
|
this.fileInputEl?.removeEventListener(
|
||||||
"change",
|
"change",
|
||||||
this.fileInputEventListener
|
this.fileInputEventListener
|
||||||
|
@ -86,7 +81,6 @@ export default Mixin.create({
|
||||||
this._unbindUploadTarget();
|
this._unbindUploadTarget();
|
||||||
this._bindFileInputChangeListener();
|
this._bindFileInputChangeListener();
|
||||||
this._bindPasteListener();
|
this._bindPasteListener();
|
||||||
this._bindMobileUploadButton();
|
|
||||||
|
|
||||||
this._uppyInstance = new Uppy({
|
this._uppyInstance = new Uppy({
|
||||||
id: this.uppyId,
|
id: this.uppyId,
|
||||||
|
|
|
@ -327,8 +327,6 @@ export default Mixin.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this._bindMobileUploadButton();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_bindMobileUploadButton() {
|
_bindMobileUploadButton() {
|
||||||
|
@ -345,13 +343,15 @@ export default Mixin.create({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@on("willDestroyElement")
|
_unbindMobileUploadButton() {
|
||||||
_unbindUploadTarget() {
|
|
||||||
this.mobileUploadButton?.removeEventListener(
|
this.mobileUploadButton?.removeEventListener(
|
||||||
"click",
|
"click",
|
||||||
this.mobileUploadButtonEventListener
|
this.mobileUploadButtonEventListener
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
@on("willDestroyElement")
|
||||||
|
_unbindUploadTarget() {
|
||||||
this._validUploads = 0;
|
this._validUploads = 0;
|
||||||
const $uploadTarget = $(this.element);
|
const $uploadTarget = $(this.element);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue