Skip to content

fix(modal): add padding-inline-end to prevent title overlapping close button - #8586

Open
sanskruti-2122 wants to merge 1 commit into
patternfly:mainfrom
sanskruti-2122:fix-modal-close-button
Open

sanskruti-2122 wants to merge 1 commit into
patternfly:mainfrom
sanskruti-2122:fix-modal-close-button

Conversation

@sanskruti-2122

@sanskruti-2122 sanskruti-2122 commented Sep 9, 2026 •

Copy link
Copy Markdown

This Pull Request fixes a layout bug where long modal header titles would bleed past their container and overlap with the "X" close button in the top-right corner.

Changes

  • Updated src/patternfly/components/ModalBox/modal-box.scss inside the .#{$modal-box}__title class.
  • Added padding-inline-end: var(--#{$modal-box}__title--PaddingInlineEnd, 3rem); to reserve a clean buffer space on the right, ensuring the title text never touches or overlaps the close button.

Related Issue

Fixes #8576

Summary by CodeRabbit

  • Style
    • Improved modal title spacing by adding configurable padding at the inline end, with a default fallback for consistent presentation.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 16c1c3d5-4797-41e0-9588-de6c638c32fe

📥 Commits

Reviewing files that changed from the base of the PR and between 1757b5d and 3ae3dba.

📒 Files selected for processing (1)
  • src/patternfly/components/ModalBox/modal-box.scss

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The modal title now uses configurable inline-end padding with a 3rem fallback.

Changes

Modal title spacing

Layer / File(s) Summary
Modal title padding
src/patternfly/components/ModalBox/modal-box.scss
The modal title uses the --pf-c-modal-box--title--PaddingInlineEnd custom property, with a 3rem fallback.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 3ae3d

Modal titles now reserve space for the close button, preventing long text from overlapping it. The focused styling change is ready to merge.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows Conventional Commits syntax with the fix type and modal scope. It accurately describes the padding change and its purpose.
Linked Issues check ✅ Passed The change adds inline-end padding to the modal title, which addresses issue #8576 by preventing title text from overlapping the close button.
Out of Scope Changes check ✅ Passed The pull request contains one focused SCSS change related to the modal title layout. No unrelated changes are present.

Warning

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jcmill
jcmill requested a review from mcoker September 10, 2026 13:07
@jcmill

jcmill commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

/deploy-preview

@patternfly-build

Copy link
Copy Markdown
Collaborator

Preview: https://pf-pr-8586.surge.sh

@mcoker mcoker left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look! The issue is actually with the close button overlapping the content below. And looks like the issue is due to different implementations in our HTML/CSS modal component and our react modal component.

In the screenshots below, I've drawn a red outline around the header element and the close button.

Here is the HTML/CSS modal - looks OK. Close button is within the header, and aligns with the title text.

Image

Here is the react modal. You can see the close button is outside of the header and not aligned with the title text.

Image

And this is the react scrolling modal.

Image

The difference is that the HTML/CSS component wraps the header contents in .pf-v6-c-modal-box__header-main which provides top padding of 8px, and the react component does not. That extra 8px pushes the header contents (title) down a little more and aligns it next to the close button better.

Ideally we would update the react component to add .pf-v6-c-modal-box__header-main inside of the header, wrapping the title, but we can't do that since that class is display: flex. Since users can pass whatever they want as the contents of the modal header, if they passed 2 or 3 elements as children, those would no longer display as they do naturally and would display as flex children instead. And that could be a breaking change for users.

Instead, we could update --#{$modal-box}__header-main--PaddingBlockStart to "0", and update --#{$modal-box}__header--PaddingBlockStart to calc(var(--pf-t--global--spacer--lg) + var(--pf-t--global--spacer--control--vertical--plain)) - effectively taking the padding off of .pf-v6-c-modal-box__header-main and adding it to .pf-v6-c-modal-box__header.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - Modal - text visible below close button

4 participants