Skip to content

A platform for community discussion. Free, open, simple.

DEV: Document `showModal`, allow setting more config via DModalBody

David Taylor35f29bd25b4d
diff --git a/app/assets/javascripts/discourse/app/components/d-modal-body.js b/app/assets/javascripts/discourse/app/components/d-modal-body.js
index 5588764a5e0..ffcac5146b7 100644
--- a/app/assets/javascripts/discourse/app/components/d-modal-body.js
+++ b/app/assets/javascripts/discourse/app/components/d-modal-body.js
@@ -41,6 +41,8 @@ export default class DModalBody extends Component {
"submitOnEnter",
"dismissable",
"headerClass",
+ "modalClass",
+ "titleAriaElementId",
])
);
}
diff --git a/app/assets/javascripts/discourse/app/components/d-modal.js b/app/assets/javascripts/discourse/app/components/d-modal.js
index b40e474e654..59e498c0266 100644
--- a/app/assets/javascripts/discourse/app/components/d-modal.js
+++ b/app/assets/javascripts/discourse/app/components/d-modal.js
@@ -93,7 +93,9 @@ export default class DModal extends Component {
}
get ariaLabelledby() {
- if (this.args.titleAriaElementId) {
+ if (this.modalBodyData.titleAriaElementId) {
+ return this.modalBodyData.titleAriaElementId;
+ } else if (this.args.titleAriaElementId) {
return this.args.titleAriaElementId;
} else if (this.args.title) {
return "discourse-modal-title";
diff --git a/app/assets/javascripts/discourse/app/lib/show-modal.js b/app/assets/javascripts/discourse/app/lib/show-modal.js
index f2628490598..ab3a3534345 100644
--- a/app/assets/javascripts/discourse/app/lib/show-modal.js
+++ b/app/assets/javascripts/discourse/app/lib/show-modal.js
@@ -2,7 +2,23 @@ import I18n from "I18n";
import { dasherize } from "@ember/string";
import { getOwner } from "discourse-common/lib/get-owner";
-export default function (name, opts) {
+/**
+ * Render a modal
+ *
+ * @param {string} name - the controller/template name for the modal body.
+ *
+ * @param {Object} [options] - options
+ * @param {string} [options.model] - An object which will be set as the `model` property on the controller
+ * @param {boolean} [options.admin] - look under the admin namespace for the controller/template
+ * @param {string} [options.templateName] - override the template name to render
+ * @param {string} [options.title] - (deprecated) translation key for modal title. Pass `@title` to DModalBody instead
+ * @param {string} [options.titleTranslated] - (deprecated) translated modal title. Pass `@rawTitle` to DModalBody instead
+ * @param {string} [options.modalClass] - (deprecated) classname for modal. Pass `@modalClass` to DModalBody instead
+ * @param {string} [options.titleAriaElementId] - (deprecated) Pass `@titleAriaElementId` to DModalBody instead
+ *
+ * @returns {Controller} The modal controller instance
+ */
+export default function showModal(name, opts) {
opts = opts || {};
let container = getOwner(this);