From f2482b5daab3f7758ab250a193f61f9d2c08156e Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 12 May 2023 18:53:54 +0100 Subject: [PATCH] DEV: Replace modal 'maxHeight' calculation with css --- .../discourse/app/components/d-modal-body.js | 25 ++++--------------- .../discourse/app/templates/modal/history.hbs | 2 +- .../app/templates/modal/raw-email.hbs | 6 +---- .../stylesheets/common/base/history.scss | 4 +++ app/assets/stylesheets/common/base/modal.scss | 2 ++ 5 files changed, 13 insertions(+), 26 deletions(-) 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 f7d6457b52c..5588764a5e0 100644 --- a/app/assets/javascripts/discourse/app/components/d-modal-body.js +++ b/app/assets/javascripts/discourse/app/components/d-modal-body.js @@ -1,5 +1,4 @@ import Component from "@glimmer/component"; -import { scheduleOnce } from "@ember/runloop"; import { disableImplicitInjections } from "discourse/lib/implicit-injections"; import { action } from "@ember/object"; import { tracked } from "@glimmer/tracking"; @@ -31,25 +30,6 @@ export default class DModalBody extends Component { $(fixedParent).modal("show"); } - scheduleOnce("afterRender", () => this._afterFirstRender(element)); - } - - @action - willDestroy() { - this.appEvents.trigger("modal:body-dismissed"); - } - - _afterFirstRender(element) { - const maxHeight = this.args.maxHeight; - if (maxHeight) { - const maxHeightFloat = parseFloat(maxHeight) / 100.0; - if (maxHeightFloat > 0) { - const viewPortHeight = $(window).height(); - element.style.maxHeight = - Math.floor(maxHeightFloat * viewPortHeight) + "px"; - } - } - this.appEvents.trigger( "modal:body-shown", pick(this.args, [ @@ -64,4 +44,9 @@ export default class DModalBody extends Component { ]) ); } + + @action + willDestroy() { + this.appEvents.trigger("modal:body-dismissed"); + } } diff --git a/app/assets/javascripts/discourse/app/templates/modal/history.hbs b/app/assets/javascripts/discourse/app/templates/modal/history.hbs index abeb4adb532..0a3d1dc6e29 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/history.hbs +++ b/app/assets/javascripts/discourse/app/templates/modal/history.hbs @@ -1,4 +1,4 @@ - +
{{d-icon "pencil-alt"}} diff --git a/app/assets/javascripts/discourse/app/templates/modal/raw-email.hbs b/app/assets/javascripts/discourse/app/templates/modal/raw-email.hbs index 6528f7fa574..c8850a9a39c 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/raw-email.hbs +++ b/app/assets/javascripts/discourse/app/templates/modal/raw-email.hbs @@ -1,8 +1,4 @@ - +