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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/image/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
4 changes: 2 additions & 2 deletions components/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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,
Expand Down