mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 00:37:06 +08:00
FIX: Ensure 'modern' modal is closed when opening legacy modal (#22689)
e.g. the modernised share-topic modal will attempt to open the `create-invite` modal. Prior to this commit, this mixing of modern/legacy would fail silently, and the create-invite modal was never shown.
This commit is contained in:
parent
e5bb4bbd59
commit
6fd06bc411
|
@ -193,6 +193,8 @@ export default class ModalServiceWithLegacySupport extends ModalService {
|
|||
return super.show(modal, opts);
|
||||
}
|
||||
|
||||
this.close({ initiatedBy: CLOSE_INITIATED_BY_MODAL_SHOW });
|
||||
|
||||
if (!KNOWN_LEGACY_MODALS.includes(modal)) {
|
||||
deprecated(
|
||||
`Defining modals using a controller is deprecated. Use the component-based API instead. (modal: ${modal})`,
|
||||
|
|
|
@ -12,6 +12,8 @@ import showModal from "discourse/lib/show-modal";
|
|||
import { registerTemporaryModule } from "../helpers/temporary-module-helper";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
||||
import Component from "@glimmer/component";
|
||||
import { setComponentTemplate } from "@glimmer/manager";
|
||||
|
||||
function silencedShowModal() {
|
||||
return withSilencedDeprecations("discourse.modal-controllers", () =>
|
||||
|
@ -142,6 +144,32 @@ acceptance("Legacy Modal", function (needs) {
|
|||
"it should not re-use the previous title"
|
||||
);
|
||||
});
|
||||
|
||||
test("opening legacy modal while modern modal is open", async function (assert) {
|
||||
registerTemporaryModule(
|
||||
"discourse/templates/modal/legacy-modal",
|
||||
hbs`<DModalBody @rawTitle="legacy modal title" />`
|
||||
);
|
||||
|
||||
class ModernModal extends Component {}
|
||||
setComponentTemplate(
|
||||
hbs`<DModal @title="modern modal title" />`,
|
||||
ModernModal
|
||||
);
|
||||
|
||||
await visit("/");
|
||||
|
||||
const modalService = getOwner(this).lookup("service:modal");
|
||||
|
||||
modalService.show(ModernModal);
|
||||
await settled();
|
||||
assert.dom(".d-modal .title").hasText("modern modal title");
|
||||
|
||||
silencedShowModal("legacy-modal");
|
||||
await settled();
|
||||
|
||||
assert.dom(".d-modal .title").hasText("legacy modal title");
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("Modal Keyboard Events", function (needs) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user