Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(dialog-box): [dialog-box] right pop-up window height style issue #2844

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
Jan 26, 2025
Merged
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
3 changes: 2 additions & 1 deletion packages/theme/src/dialog-box/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@
overflow: auto;
color: var(--tv-DialogBox-drawer-body-color);
border-bottom: 1px solid var(--tv-DialogBox-drawer-divider-border-color);
padding: 0 var(--tv-DialogBox-padding);
padding: var(--tv-DialogBox-vertical-padding) var(--tv-DialogBox-padding);
max-height: 100vh;

Choose a reason for hiding this comment

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

Ensure that the max-height: 100vh; does not interfere with any dynamic content that might exceed this height, as it could lead to content being cut off or inaccessible.

Comment on lines +185 to +186
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider a more robust height calculation approach.

While the padding changes look good, setting max-height: 100vh might cause issues:

  1. Content could overflow or be cut off since the drawer has header and footer sections
  2. Mobile browsers with dynamic toolbars can cause inconsistent viewport heights

Consider this alternative approach:

 .@{dialog-box-prefix-cls}__body {
   flex: 1;
   overflow: auto;
   color: var(--tv-DialogBox-drawer-body-color);
   border-bottom: 1px solid var(--tv-DialogBox-drawer-divider-border-color);
   padding: var(--tv-DialogBox-vertical-padding) var(--tv-DialogBox-padding);
-  max-height: 100vh;
+  max-height: calc(100vh - var(--tv-DialogBox-padding) * 2 - var(--tv-DialogBox-header-height) - var(--tv-DialogBox-footer-height));
+  /* Add a CSS variable for dynamic viewport height support */
+  max-height: calc(100dvh - var(--tv-DialogBox-padding) * 2 - var(--tv-DialogBox-header-height) - var(--tv-DialogBox-footer-height));
 }

This change:

  1. Accounts for header/footer heights and padding
  2. Uses dvh unit as a fallback for browsers that support dynamic viewport units
  3. Relies on CSS variables for maintainable height calculations

Note: You'll need to define the header and footer height variables in your vars.less file.

Committable suggestion skipped: line range outside the PR's diff.

}

.@{dialog-box-prefix-cls}__footer {
Expand Down
Loading