Skip to content

Commit

Permalink
feat: preview zIndex should pass into operations (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiner-tang authored Nov 21, 2023
1 parent cd92f7d commit d2f3f62
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/examples/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function Base() {
onVisibleChange: visible => {
console.log('visible', visible);
},
zIndex: 9999
}}
/>

Expand Down
7 changes: 6 additions & 1 deletion src/Operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface OperationsProps
originalNode: React.ReactElement,
info: ToolbarRenderInfoType | Omit<ToolbarRenderInfoType, 'current' | 'total'>,
) => React.ReactNode;
zIndex?: number;
}

const Operations: React.FC<OperationsProps> = props => {
Expand Down Expand Up @@ -71,6 +72,7 @@ const Operations: React.FC<OperationsProps> = props => {
onFlipX,
onFlipY,
toolbarRender,
zIndex,
} = props;
const groupContext = useContext(PreviewGroupContext);
const { rotateLeft, rotateRight, zoomIn, zoomOut, close, left, right, flipX, flipY } = icons;
Expand Down Expand Up @@ -148,7 +150,10 @@ const Operations: React.FC<OperationsProps> = props => {
<Portal open getContainer={getContainer ?? document.body}>
<div
className={classnames(`${prefixCls}-operations-wrapper`, className, rootClassName)}
style={style}
style={{
...style,
zIndex,
}}
>
{closeIcon === null ? null : (
<button className={`${prefixCls}-close`} onClick={onClose}>
Expand Down
1 change: 1 addition & 0 deletions src/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ const Preview: React.FC<PreviewProps> = props => {
onFlipX={onFlipX}
onFlipY={onFlipY}
onClose={onClose}
zIndex={restProps.zIndex}
/>
</>
);
Expand Down
10 changes: 10 additions & 0 deletions tests/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ describe('Basic', () => {
const maskElement = container.querySelector('.rc-image-mask');
expect(maskElement).toHaveStyle({ display: 'none' });
});
it('preview zIndex should pass into operations', () => {
const { baseElement } = render(
<Image
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
preview={{ zIndex: 9999, visible: true }}
/>,
);
const operationsElement = baseElement.querySelector('.rc-image-preview-operations-wrapper');
expect(operationsElement).toHaveStyle({ zIndex: 9999 });
});
});

1 comment on commit d2f3f62

@vercel
Copy link

@vercel vercel bot commented on d2f3f62 Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.