Skip to content

UX: improve header alignment in mobile modals #34260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions app/assets/javascripts/discourse/app/components/d-modal.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export default class DModal extends Component {
return this.args.autofocus ?? true;
}

get mobileDismissable() {
return this.site.mobileView && this.dismissable;
}

shouldTriggerClickOnEnter(event) {
if (this.args.submitOnEnter === false) {
return false;
Expand Down Expand Up @@ -340,7 +344,14 @@ export default class DModal extends Component {
)
}}
<div
class={{concatClass "d-modal__header" @headerClass}}
class={{concatClass
"d-modal__header"
(if
(and this.mobileDismissable (has-block "headerPrimaryAction"))
"--has-primary-action"
)
@headerClass
}}
{{swipe
onDidSwipe=this.handleSwipe
onDidEndSwipe=this.handleSwipeEnded
Expand All @@ -350,11 +361,7 @@ export default class DModal extends Component {
{{yield to="headerAboveTitle"}}

{{#if
(and
this.site.mobileView
this.dismissable
(has-block "headerPrimaryAction")
)
(and this.mobileDismissable (has-block "headerPrimaryAction"))
}}
<div class="d-modal__dismiss-action">
<DButton
Expand Down
6 changes: 5 additions & 1 deletion app/assets/stylesheets/common/base/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ html:not(.keyboard-visible.mobile-view) {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 0.5rem 0.5rem 1.5rem; // offset for close button padding
padding: 0.5rem;
border-bottom: 1px solid var(--content-border-color);

&:not(.--has-primary-action) {
padding: 0.5rem 0.5rem 0.5rem 1.5rem; // offset for close button padding
}

.modal-close {
margin-left: auto;
align-self: start;
Expand Down
Loading