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: Image inline rendering not work when getContainer is false #47034

Merged

Conversation

FEyudong
Copy link
Contributor

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 工作流程
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

无相关issue

💡 需求背景和解决方案

  • 需求背景
    Image 组件 preview.getContainer=false 依据使用文档,表示图像预览框在组件DOM容器内渲染,但实际并不生效,依旧是挂载在了 document.body 下的全局位置。
  • 解决方案
    产生此问题的原因是 preview.getContainer属性在透传给 rc-image 组件时,使用 || 做空值兼容,但忽略了其值可能会为 false 的情况。所以解决方案:1. 显式的忽略 false 的判空兼容 getContainer: getContainer || getContainer === false ? getContainer : getContextPopupContainer, 2. 使用 ?? 代替 || 做空值合并。 这里使用了方案1,是为了更明确的表示其值会为 false 的特殊处理。

📝 更新日志

语言 更新描述
🇺🇸 英文 Fixed an issue where the inline rendering does not take effect when the preview.getContainer value of the Image component is set to false
🇨🇳 中文 修复 Image 组件 preview.getContainer 值为 false时,内联渲染不生效的问题

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

Copy link

stackblitz bot commented Jan 18, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Contributor

github-actions bot commented Jan 18, 2024

Preview Is ready

Copy link
Contributor

github-actions bot commented Jan 18, 2024

Visual Regression Report for PR #47034 Failed ❌

Target branch: master (e6e260d)
View Full Report


image name expected actual diff
qr-code-Popover.dark.png master: e6e260db77bb1e1c15d683326dd0ac3c57ccf2f1 current: pr-47034 diff
qr-code-Popover.dark.css-var.png master: e6e260db77bb1e1c15d683326dd0ac3c57ccf2f1 current: pr-47034 diff

Check Full Report for details

Copy link

codesandbox-ci bot commented Jan 18, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a9f3a10:

Sandbox Source
antd reproduction template (forked) Configuration

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e7d4d65) 100.00% compared to head (a9f3a10) 100.00%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #47034   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          732       732           
  Lines        12552     12552           
  Branches      3293      3293           
=========================================
  Hits         12552     12552           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@li-jia-nan li-jia-nan changed the title fix: Image 组件 preview.getContainer=false 内联渲染不生效 fix: Image inline rendering not work when getContainer is false Jan 18, 2024
@li-jia-nan li-jia-nan merged commit a7cff93 into ant-design:master Jan 18, 2024
64 of 65 checks passed
Copy link
Contributor

🎉 Thank you for your contribution! If you have not yet joined our DingTalk community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您还没有加入钉钉社区群,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

@vagusX vagusX mentioned this pull request Jan 19, 2024
MadCcc pushed a commit that referenced this pull request Jan 29, 2024
* fix: Image 组件 preview.getContainer=false 内联渲染不生效

* refactor: Image.preview.getContainer 空值合并逻辑

---------

Co-authored-by: 莫青 <zhengyudong.zyd@alibaba-inc.com>
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.

None yet

2 participants