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
fix: Image inline rendering not work when getContainer is false #47034
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Visual Regression Report for PR #47034 Failed ❌
Check Full Report for details |
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:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
* fix: Image 组件 preview.getContainer=false 内联渲染不生效 * refactor: Image.preview.getContainer 空值合并逻辑 --------- Co-authored-by: 莫青 <zhengyudong.zyd@alibaba-inc.com>
🤔 这个变动的性质是?
🔗 相关 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
的特殊处理。📝 更新日志
☑️ 请求合并前的自查清单