table icon indicating copy to clipboard operation
table copied to clipboard

fix: emptyNode should not shaked when horizontal scroll

Open linxianxi opened this issue 1 year ago • 3 comments

fix https://github.com/ant-design/ant-design/issues/49279

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

问题的本质是因为第一次 render 时无法获取到 componentWidth 并展示。componentWidth 是 ResizeObserver 监听后 setComponentWidth 上去的。

或许 ResizeObserver 改用 useLayoutEffect 监听宽度可完美解?

linxianxi avatar Jun 06 '24 08:06 linxianxi

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

vercel[bot] avatar Jun 06 '24 08:06 vercel[bot]

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

zombieJ avatar Jun 06 '24 14:06 zombieJ

这样闪一下体验更糟吧

linxianxi avatar Jun 07 '24 05:06 linxianxi

冲突解决一下我合并

afc163 avatar May 14 '25 08:05 afc163

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

A member of the Team first needs to authorize it.

vercel[bot] avatar May 14 '25 09:05 vercel[bot]

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: 渲染结果

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.

coderabbitai[bot] avatar May 14 '25 09:05 coderabbitai[bot]