Merge pull request #34193 from adatta-chwy/passing-option-for-centering-dialog-box

feat: Adding option to centre frappe Dialog Box
This commit is contained in:
Ejaaz Khan 2025-09-29 23:11:21 +05:30 committed by GitHub
commit 687aae4915
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -14,7 +14,7 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup {
this.is_dialog = true;
this.last_focus = null;
$.extend(this, { animate: true, size: null, auto_make: true }, opts);
$.extend(this, { animate: true, size: null, auto_make: true, centered: false }, opts);
if (this.auto_make) {
this.make();
}
@ -34,6 +34,7 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup {
if (!this.size) this.set_modal_size();
this.wrapper = this.$wrapper.find(".modal-dialog").get(0);
if (this.centered) $(this.wrapper).addClass("modal-dialog-centered");
if (this.size == "small") $(this.wrapper).addClass("modal-sm");
else if (this.size == "large") $(this.wrapper).addClass("modal-lg");
else if (this.size == "extra-large") $(this.wrapper).addClass("modal-xl");

View file

@ -345,3 +345,13 @@ body.modal-open[style^="padding-right"] {
}
}
}
.modal-dialog-centered {
display: flex;
align-items: center;
min-height: calc(100% - 1rem);
}
@media (min-width: 576px) {
.modal-dialog-centered {
min-height: calc(100% - 3.5rem);
}
}