mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-29 18:50:00 +08:00
fix: Image inline rendering not work when getContainer is false (#47034)
* fix: Image 组件 preview.getContainer=false 内联渲染不生效 * refactor: Image.preview.getContainer 空值合并逻辑 --------- Co-authored-by: 莫青 <zhengyudong.zyd@alibaba-inc.com>
This commit is contained in:
parent
023f3ec719
commit
a7cff93db7
@ -55,12 +55,19 @@ describe('Image', () => {
|
||||
const { container, baseElement } = render(
|
||||
<Image
|
||||
src={src}
|
||||
preview={{ visible: true, transitionName: 'abc', maskTransitionName: 'def' }}
|
||||
preview={{
|
||||
visible: true,
|
||||
transitionName: 'abc',
|
||||
maskTransitionName: 'def',
|
||||
getContainer: false,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(container.querySelector('.ant-image')!);
|
||||
|
||||
expect(container.querySelector('.ant-image-preview-root')).not.toBe(null);
|
||||
|
||||
expect(baseElement.querySelector('.ant-image-preview')).toHaveClass('abc');
|
||||
expect(baseElement.querySelector('.ant-image-preview-mask')).toHaveClass('def');
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ const Image: CompositionImage<ImageProps> = (props) => {
|
||||
typeof preview === 'object' ? preview.zIndex : undefined,
|
||||
);
|
||||
|
||||
const mergedPreview = React.useMemo(() => {
|
||||
const mergedPreview = React.useMemo<ImageProps['preview']>(() => {
|
||||
if (preview === false) {
|
||||
return preview;
|
||||
}
|
||||
@ -64,7 +64,7 @@ const Image: CompositionImage<ImageProps> = (props) => {
|
||||
),
|
||||
icons,
|
||||
...restPreviewProps,
|
||||
getContainer: getContainer || getContextPopupContainer,
|
||||
getContainer: getContainer ?? getContextPopupContainer,
|
||||
transitionName: getTransitionName(rootPrefixCls, 'zoom', _preview.transitionName),
|
||||
maskTransitionName: getTransitionName(rootPrefixCls, 'fade', _preview.maskTransitionName),
|
||||
zIndex,
|
||||
|
Loading…
Reference in New Issue
Block a user