Skip to content
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

fix: layout and Page style adjustment #5033

Closed
wants to merge 5 commits into from

Conversation

mynetfan
Copy link
Collaborator

@mynetfan mynetfan commented Dec 5, 2024

Description

修复表格在窗口尺寸变小时,自动调整尺寸会变得非常缓慢的BUG;
修复Page组件的footer没有固定在底部的问题;
修复表格自定义列宽度超出页面宽度时,滚动条出现在页面而不是表格内的问题;

页面容器div的overflow-hidden移除之后会产生表格宽度计算问题,但添加overflow-hidden又会造成page组件内的header无法使用sticky定位。此PR恢复了页面容器的overflow-hidden类,将page组件的header和footer定位修改为fixed

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Enhanced layout responsiveness with new CSS classes and dynamic calculations for header and footer dimensions.
    • Introduced a fixed-header property to improve table header display in the basic example.
  • Bug Fixes

    • Improved handling of sidebar and header visibility based on mobile state and scroll events.
  • Documentation

    • Updated documentation for the Page component to include versioning for props and clarify the functionality of the fixedHeader property.

Copy link

changeset-bot bot commented Dec 5, 2024

⚠️ No Changeset found

Latest commit: 08e2744

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/@core/ui-kit/layout-ui/src/vben-layout.vue

Oops! Something went wrong! :(

ESLint: 9.16.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/@vben/eslint-config/dist/index.mjs' imported from /eslint.config.mjs
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:914:10)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

Walkthrough

The pull request introduces several modifications to the layout components, primarily focusing on enhancing responsiveness and styling. In vben-layout.vue, new CSS classes and refined computed properties improve layout behavior, particularly for the sidebar and header. The page.vue component sees the introduction of dynamic CSS variables for header and footer dimensions, enhancing its responsiveness. Additionally, a new property fixed-header is added to the basic.vue file, affecting the rendering of the table header. Overall, these changes aim to improve layout management across components.

Changes

File Path Change Summary
packages/@core/ui-kit/layout-ui/src/vben-layout.vue Added overflow-hidden class, refined computed properties (headerWrapperHeight, getSidebarWidth, etc.), updated watch functions for responsiveness.
packages/effects/common-ui/src/components/page/page.vue Introduced CSS variables for headerHeight and footerHeight, updated headerStyle, added footerStyle, modified contentStyle.
playground/src/views/examples/vxe-table/basic.vue Added fixed-header property to <Page> component in the template.
docs/src/components/layout-ui/page.md Updated documentation for the Page component to include versioning for props and clarified fixedHeader usage.

Assessment against linked issues

Objective Addressed Explanation
Fix the issue of table width decreasing on window resize (#5027)
Ensure footer is positioned at the bottom when set (#5021)
Resolve styling issues when using Page component with grid (#5028)

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • vince292007
  • anncwb

Poem

🐰 In the layout's dance, we twirl and spin,
Overflow hidden, let the fun begin!
With headers fixed and sidebars wide,
Our UI's a joy, come take a ride!
Responsive and bright, like a sunny day,
Hopping through code, in a playful way! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (1)
packages/effects/common-ui/src/components/page/page.vue (1)

103-105: Replace setTimeout with nextTick for reactive updates

Using setTimeout may introduce unnecessary delays and can be less reliable across different environments. nextTick is more suitable for waiting until the DOM updates have been applied.

Modify the calcContentHeight function:

setTimeout(() => {
  shouldAutoHeight.value = true;
- }, 30);
+ });

Or use nextTick:

await nextTick();
shouldAutoHeight.value = true;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 21d37a1 and 22cca69.

📒 Files selected for processing (3)
  • packages/@core/ui-kit/layout-ui/src/vben-layout.vue (1 hunks)
  • packages/effects/common-ui/src/components/page/page.vue (5 hunks)
  • playground/src/views/examples/vxe-table/basic.vue (1 hunks)
🔇 Additional comments (5)
packages/effects/common-ui/src/components/page/page.vue (2)

Line range hint 140-161: Optimize slot usage within header

Wrapping the title and description slots within a div with class "flex-auto" might impact the layout if not handled carefully. Ensure that this additional wrapper does not introduce unwanted side effects.

Please verify that the new wrapper maintains the intended layout and styling, especially in responsive scenarios.


83-93: ⚠️ Potential issue

Prevent content overlap with fixed footer

When the footer is fixed, the content may overlap with it if no margin or padding is added to the content area. To ensure a seamless layout, adjust the content area to account for the footer height.

Modify the contentStyle to include paddingBottom when the footer is fixed:

if (footerHeight.value > 0 && preferences.footer.fixed) {
  style.marginBottom = `${footerHeight.value}px`;
+ style.paddingBottom = `${footerHeight.value}px`;
}

Likely invalid or redundant comment.

playground/src/views/examples/vxe-table/basic.vue (1)

74-74: Appropriate use of fixed-header prop in <Page> component

Adding the fixed-header prop to the <Page> component enables the fixed header feature as intended. This aligns with the recent updates to the Page component and addresses the issues related to header positioning.

packages/@core/ui-kit/layout-ui/src/vben-layout.vue (2)

506-506: Adding overflow-hidden class improves layout stability

Restoring the overflow-hidden class to the main content div addresses the table width calculation issues and prevents unwanted scrollbars from appearing. This change fixes the layout problems outlined in the PR objectives.


506-506: Verify impact of overflow-hidden on child components

While overflow-hidden resolves certain layout issues, it may inadvertently hide overflowing content from child components like modals or dropdown menus. Ensure that this change does not negatively affect components that rely on overflow visibility.

Please test interactive components that may extend outside their parent container to confirm they display correctly.

@1055031918
Copy link

你给vben-layout加overflow-hidden会导致表格失去高度,在表格为树的情况下刷新页面,会在一些情况下没有高度,比如从其他页面跳转到树表格
image

@mynetfan mynetfan force-pushed the fix/layout-page-style branch from 444335a to 08e2744 Compare December 6, 2024 05:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
docs/src/components/layout-ui/page.md (2)

21-29: Enhance props documentation for better clarity

While the props table is well-structured, consider the following improvements:

  1. Expand the fixedHeader description to explicitly mention its relationship with header.mode, similar to how it's described in the note below.
  2. Consider adding examples or default values for headerClass and footerClass to guide users on common usage patterns.
| fixedHeader | 固定头部在页面内容区域顶部,在滚动时保持可见 | `boolean` | `false` | `v5.5.0` |
+| fixedHeader | 固定头部在页面内容区域顶部,在滚动时保持可见(仅在 header.mode 为 fixed 时生效) | `boolean` | `false` | `v5.5.0` |

33-33: Add layout considerations to the documentation

Given the layout-related fixes in this PR, consider expanding the note to include:

  1. A reference to the header mode documentation
  2. Common layout considerations when using fixedHeader
  3. Potential impact on table layouts and scrolling behavior
-如果`title`、`description`、`extra`三者均未提供有效内容(通过`props`或者`slots`均可),则页面头部区域不会渲染。另外,`fixedHeader`属性目前仅在顶栏模式(`header.mode`)为`固定`(`fixed`)时有效。
+如果`title`、`description`、`extra`三者均未提供有效内容(通过`props`或者`slots`均可),则页面头部区域不会渲染。另外,`fixedHeader`属性目前仅在顶栏模式(`header.mode`)为`固定`(`fixed`)时有效。启用`fixedHeader`时,请注意:
+
+1. 确保父容器具有明确的高度定义
+2. 表格布局可能需要额外的滚动容器配置
+3. 树形表格可能需要特殊处理以维持正确的高度
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ef2d4ff and 08e2744.

📒 Files selected for processing (4)
  • docs/src/components/layout-ui/page.md (1 hunks)
  • packages/@core/ui-kit/layout-ui/src/vben-layout.vue (1 hunks)
  • packages/effects/common-ui/src/components/page/page.vue (5 hunks)
  • playground/src/views/examples/vxe-table/basic.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • playground/src/views/examples/vxe-table/basic.vue
  • packages/effects/common-ui/src/components/page/page.vue
  • packages/@core/ui-kit/layout-ui/src/vben-layout.vue

@mynetfan
Copy link
Collaborator Author

mynetfan commented Dec 6, 2024

你给vben-layout加overflow-hidden会导致表格失去高度,在表格为树的情况下刷新页面,会在一些情况下没有高度,比如从其他页面跳转到树表格 image

表格高度问题与overflow-hidden无关。即便是没有overflow-hidden,来回切换tab也可能会出现表格高度计算问题。参考:
#5015#5035

@mynetfan mynetfan closed this Dec 6, 2024
@1055031918
Copy link

1055031918 commented Dec 6, 2024

这个问题我解决了,我将packages\effects\common-ui\src\components\page\page.vue内calcContentHeight方法改为了以下代码

const renderContent = ref(false);

async function calcContentHeight() {
if (autoContentHeight) {
shouldAutoHeight.value = true;
}
await nextTick();
setTimeout(() => {
renderContent.value = true;
}, 30);
}

然后使用去控制default插槽渲染,解决了这个问题

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.

2 participants