Skip to content

fix: emptyNode should not shaked when horizontal scroll #1142

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 2 commits into from
May 14, 2025

Conversation

linxianxi
Copy link
Contributor

@linxianxi linxianxi commented Jun 6, 2024

fix ant-design/ant-design#49279

虽然不会有位置上的变动,但是这样会展示一下白屏再展示 Empty,体验会好一些。

问题的本质是因为第一次 render 时无法获取到 componentWidth 并展示。componentWidth 是 ResizeObserver 监听后还通过 getContainerWidth 然后 setComponentWidth 上去的。这个 pr 还无法完美解决

Summary by CodeRabbit

  • Bug Fixes
    • 修复了在行为空、启用横向滚动且组件宽度为零或未定义时,展开行可能显示异常的问题。现在在这些情况下内容将被正确隐藏,提升了界面显示的一致性。

Copy link

vercel bot commented Jun 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
table ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2025 9:09am

@zombieJ
Copy link
Member

zombieJ commented Jun 6, 2024

Table 的一些时序可以合并掉。不过要重构就比较麻烦。现在如果是白屏的话,ssr 体验就比较糟糕了(我印象里header就是白的,就不太好)。

@linxianxi
Copy link
Contributor Author

这样闪一下体验更糟吧

@afc163
Copy link
Member

afc163 commented May 14, 2025

冲突解决一下我合并

@linxianxi linxianxi force-pushed the fix-scrollx-empty branch from 67cc908 to 7bdc9ca Compare May 14, 2025 09:06
Copy link

vercel bot commented May 14, 2025

@linxianxi is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented May 14, 2025

Walkthrough

本次更改在 ExpandedRow 组件中,为根元素添加了条件性的 visibility 样式。当行为空、允许横向滚动且组件宽度为假值时,将 visibility 设为 hidden,以解决空状态初始渲染时的显示问题。

Changes

文件/文件组 变更摘要
src/Body/ExpandedRow.tsx 在根元素样式中增加了条件性的 visibility 属性,用于特定条件下隐藏空状态内容。

Sequence Diagram(s)

sequenceDiagram
    participant Parent
    participant ExpandedRow

    Parent->>ExpandedRow: 渲染组件,传递 isEmpty、horizonScroll、componentWidth 等属性
    ExpandedRow->>ExpandedRow: 判断 isEmpty && horizonScroll && !componentWidth
    alt 条件成立
        ExpandedRow->>ExpandedRow: 设置 visibility: 'hidden'
    else 条件不成立
        ExpandedRow->>ExpandedRow: visibility 不变
    end
    ExpandedRow->>Parent: 渲染结果
Loading

Assessment against linked issues

Objective Addressed Explanation
空状态在横向滚动时应一开始居中显示,避免初始闪动 (#49279)

Suggested reviewers

  • zombieJ
  • afc163

Poem

🐇
空行闪现一瞬间,
代码轻抚隐形帘。
横滚之下藏玄机,
居中展现不再偏。
小兔欢跳来贺变!

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.

src/Body/ExpandedRow.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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

@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

🧹 Nitpick comments (2)
src/Body/ExpandedRow.tsx (2)

64-64: 细化注释以增加可读性和上下文
当前注释仅提供了 Issue 链接,建议补充描述性文字,说明为何在此处需要隐藏元素,以便在离线阅读或后续维护时能快速了解本行变更的意图。


65-65: 验证 SSR 场景下的表现及优化样式定义
新增的 visibility 控制依赖于 isEmpty && horizonScroll && !componentWidth,请确认在服务端渲染(SSR)环境中 horizonScrollcomponentWidth 的默认值,避免出现意外的内容隐藏或白屏闪烁。此外,为了与 React 对 style 属性的惯例保持一致,建议将 null 替换为 undefined,从而保证在不需要时该属性不会被注入到最终的 DOM。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2e4ac9 and 7bdc9ca.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/FixedColumn.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • src/Body/ExpandedRow.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test / react component workflow

@afc163 afc163 merged commit b4ceb29 into react-component:master May 14, 2025
7 checks passed
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.

Table 可横向滚动时,空状态会闪动
3 participants