A platform for community discussion. Free, open, simple.
Revert "DEV: allows to intercept the closeModal early (#36097)" (#36100)
Joffrey JAFFEUX520f2c0df641
diff --git a/frontend/discourse/app/components/d-modal.gjs b/frontend/discourse/app/components/d-modal.gjsindex f0a5b540b23..54799d282b3 100644--- a/frontend/discourse/app/components/d-modal.gjs+++ b/frontend/discourse/app/components/d-modal.gjs@@ -180,13 +180,6 @@ export default class DModal extends Component {return;}- if (this.args.shouldClose) {- const shouldClose = await this.args.shouldClose({ initiatedBy }, event);- if (shouldClose === false) {- return;- }- }-try {this.animating = true;diff --git a/frontend/discourse/app/components/modal/spreadsheet-editor.gjs b/frontend/discourse/app/components/modal/spreadsheet-editor.gjsindex 684ff973a69..6b97b2f8a63 100644--- a/frontend/discourse/app/components/modal/spreadsheet-editor.gjs+++ b/frontend/discourse/app/components/modal/spreadsheet-editor.gjs@@ -77,15 +77,15 @@ export default class SpreadsheetEditor extends Component {}@action- async interceptCloseModal() {+ interceptCloseModal() {if (this._hasChanges()) {- return await this.dialog.yesNoConfirm({+ this.dialog.yesNoConfirm({message: i18n("table_builder.modal.confirm_close"),- didConfirm: () => true,+ didConfirm: () => this.args.closeModal(),});+ } else {+ this.args.closeModal();}-- return true;}@action@@ -349,8 +349,7 @@ export default class SpreadsheetEditor extends Component {<template><DModal@title={{i18n this.modalAttributes.title}}- @closeModal={{@closeModal}}- @shouldClose={{this.interceptCloseModal}}+ @closeModal={{this.interceptCloseModal}}class="insert-table-modal"><:body>@@ -373,7 +372,7 @@ export default class SpreadsheetEditor extends Component {class="btn-insert-table"/>- <DModalCancel />+ <DModalCancel @close={{this.interceptCloseModal}} /></div><div class="secondary-actions">diff --git a/frontend/discourse/tests/integration/components/d-modal-test.gjs b/frontend/discourse/tests/integration/components/d-modal-test.gjsindex 7d60df96130..0f5edddb2ee 100644--- a/frontend/discourse/tests/integration/components/d-modal-test.gjs+++ b/frontend/discourse/tests/integration/components/d-modal-test.gjs@@ -106,45 +106,6 @@ module("Integration | Component | d-modal", function (hooks) {assert.dom(".d-modal .alert").hasText("Some message");});- test("shouldClose", async function (assert) {- class TestState {- shouldCloseModal = false;- closeModalCalled = false;-- @action- closeModal() {- this.closeModalCalled = true;- }-- @action- shouldClose() {- return this.shouldCloseModal;- }- }-- const testState = new TestState();-- await render(- <template>- <DModal- @inline={{true}}- @closeModal={{testState.closeModal}}- @shouldClose={{testState.shouldClose}}- />- </template>- );-- await click(".d-modal .modal-close");-- assert.false(testState.closeModalCalled);-- testState.shouldCloseModal = true;-- await click(".d-modal .modal-close");-- assert.true(testState.closeModalCalled);- });-test("flash type", async function (assert) {await render(<template>