Skip to content

Commit d2f3f62

Browse files
authored
feat: preview zIndex should pass into operations (#288)
1 parent cd92f7d commit d2f3f62

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

docs/examples/basic.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function Base() {
4141
onVisibleChange: visible => {
4242
console.log('visible', visible);
4343
},
44+
zIndex: 9999
4445
}}
4546
/>
4647

src/Operations.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ interface OperationsProps
4141
originalNode: React.ReactElement,
4242
info: ToolbarRenderInfoType | Omit<ToolbarRenderInfoType, 'current' | 'total'>,
4343
) => React.ReactNode;
44+
zIndex?: number;
4445
}
4546

4647
const Operations: React.FC<OperationsProps> = props => {
@@ -71,6 +72,7 @@ const Operations: React.FC<OperationsProps> = props => {
7172
onFlipX,
7273
onFlipY,
7374
toolbarRender,
75+
zIndex,
7476
} = props;
7577
const groupContext = useContext(PreviewGroupContext);
7678
const { rotateLeft, rotateRight, zoomIn, zoomOut, close, left, right, flipX, flipY } = icons;
@@ -148,7 +150,10 @@ const Operations: React.FC<OperationsProps> = props => {
148150
<Portal open getContainer={getContainer ?? document.body}>
149151
<div
150152
className={classnames(`${prefixCls}-operations-wrapper`, className, rootClassName)}
151-
style={style}
153+
style={{
154+
...style,
155+
zIndex,
156+
}}
152157
>
153158
{closeIcon === null ? null : (
154159
<button className={`${prefixCls}-close`} onClick={onClose}>

src/Preview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ const Preview: React.FC<PreviewProps> = props => {
411411
onFlipX={onFlipX}
412412
onFlipY={onFlipY}
413413
onClose={onClose}
414+
zIndex={restProps.zIndex}
414415
/>
415416
</>
416417
);

tests/basic.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,14 @@ describe('Basic', () => {
8787
const maskElement = container.querySelector('.rc-image-mask');
8888
expect(maskElement).toHaveStyle({ display: 'none' });
8989
});
90+
it('preview zIndex should pass into operations', () => {
91+
const { baseElement } = render(
92+
<Image
93+
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
94+
preview={{ zIndex: 9999, visible: true }}
95+
/>,
96+
);
97+
const operationsElement = baseElement.querySelector('.rc-image-preview-operations-wrapper');
98+
expect(operationsElement).toHaveStyle({ zIndex: 9999 });
99+
});
90100
});

0 commit comments

Comments
 (0)