diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index 7cab8501f35..2b43c5a17bd 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -86,15 +86,6 @@ export class AttachmentViewer extends Component { // Private //-------------------------------------------------------------------------- - /** - * Close the dialog with this attachment viewer. - * - * @private - */ - _close() { - this.attachmentViewer.delete(); - } - /** * Determine whether the current image is rendered for the 1st time, and if * that's the case, display a spinner until loaded. @@ -290,7 +281,7 @@ export class AttachmentViewer extends Component { } // TODO: clicking on the background should probably be handled by the dialog? // task-2092965 - this._close(); + this.attachmentViewer.close(); } /** @@ -300,7 +291,7 @@ export class AttachmentViewer extends Component { * @param {MouseEvent} ev */ _onClickClose(ev) { - this._close(); + this.attachmentViewer.close(); } /** @@ -455,10 +446,10 @@ export class AttachmentViewer extends Component { this._previous(); break; case 'Escape': - this._close(); + this.attachmentViewer.close(); break; case 'q': - this._close(); + this.attachmentViewer.close(); break; case 'r': this._rotate(); diff --git a/addons/mail/static/src/models/attachment_viewer.js b/addons/mail/static/src/models/attachment_viewer.js index ffe17cf8a06..9123e61b594 100644 --- a/addons/mail/static/src/models/attachment_viewer.js +++ b/addons/mail/static/src/models/attachment_viewer.js @@ -7,6 +7,12 @@ registerModel({ name: 'AttachmentViewer', identifyingFields: ['dialogOwner'], recordMethods: { + /** + * Close the dialog with this attachment viewer. + */ + close() { + this.delete(); + }, /** * Returns whether the given html element is inside this attachment viewer. *