0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed email preview input dropdown not closing when clicking on iframe

no issue

- clicks on the iframe never bubble out of the iframe so weren't captured by the dropdown-closing event listener
- added an event listener directly on the iframe's body element when we render the iframe's content that manually calls out to our generic dropdown closing method
This commit is contained in:
Kevin Ansfield 2023-01-23 09:47:33 +00:00
parent 4b61f23bd0
commit 42b30ac613
2 changed files with 7 additions and 0 deletions

View file

@ -32,6 +32,7 @@ const SEGMENT_OPTIONS = [{
// TODO: remove duplication with <ModalPostEmailPreview>
export default class ModalPostPreviewEmailComponent extends Component {
@service ajax;
@service dropdown;
@service feature;
@service ghostPaths;
@service session;
@ -76,6 +77,9 @@ export default class ModalPostPreviewEmailComponent extends Component {
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(this.html);
iframe.contentWindow.document.close();
iframe.contentWindow.document.removeEventListener('click', this.dropdown.closeDropdowns);
iframe.contentWindow.document.addEventListener('click', this.dropdown.closeDropdowns);
}
}

View file

@ -4,6 +4,7 @@ import classic from 'ember-classic-decorator';
import BodyEventListener from 'ghost-admin/mixins/body-event-listener';
import Evented from '@ember/object/evented';
import Service from '@ember/service';
import {action} from '@ember/object';
@classic
export default class DropdownService extends Service.extend(Evented, BodyEventListener) {
@ -15,10 +16,12 @@ export default class DropdownService extends Service.extend(Evented, BodyEventLi
}
}
@action
closeDropdowns() {
this.trigger('close');
}
@action
toggleDropdown(dropdownName, dropdownButton) {
this.trigger('toggle', {target: dropdownName, button: dropdownButton});
}