diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index fe9746bce95..f19efa56334 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -3077,6 +3077,28 @@ options.registry.ScrollButton = options.Class.extend({ this.$button.detach(); } }, + /** + * @override + */ + async selectClass(previewMode, widgetValue, params) { + await this._super(...arguments); + // If a "d-lg-block" class exists on the section (e.g., for mobile + // visibility option), it should be replaced with a "d-lg-flex" class. + // This ensures that the section has the "display: flex" property + // applied, which is the default rule for both "height" option classes. + if (params.possibleValues.includes("o_half_screen_height")) { + if (widgetValue) { + this.$target[0].classList.replace("d-lg-block", "d-lg-flex"); + } else if (this.$target[0].classList.contains("d-lg-flex")) { + // There are no known cases, but we still make sure that the + //
element doesn't have a "display: flex" originally. + this.$target[0].classList.remove("d-lg-flex"); + const sectionStyle = window.getComputedStyle(this.$target[0]); + const hasDisplayFlex = sectionStyle.getPropertyValue("display") === "flex"; + this.$target[0].classList.add(hasDisplayFlex ? "d-lg-flex" : "d-lg-block"); + } + } + }, //-------------------------------------------------------------------------- // Private diff --git a/addons/website/static/src/scss/website.wysiwyg.scss b/addons/website/static/src/scss/website.wysiwyg.scss index ec2c4f133ab..2ed8c7fc472 100644 --- a/addons/website/static/src/scss/website.wysiwyg.scss +++ b/addons/website/static/src/scss/website.wysiwyg.scss @@ -48,6 +48,10 @@ html[data-edit_translations="1"] { opacity: 70%; position: relative; + &.d-lg-flex, &.d-md-flex, &.o_half_screen_height, &.o_full_screen_height { + // e.g. Useful if "Height" option (50% or 100%) is enabled. + display: flex !important; + } &::before { position: absolute; // Content is 0px wide => use available width.