Skip to content

Commit

Permalink
fix: only one group item should have operation-process (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
berber1016 committed Aug 31, 2022
1 parent 0ff6289 commit 7acbbfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const Preview: React.FC<PreviewProps> = props => {
const currentPreviewIndex = previewUrlsKeys.indexOf(current);
const combinationSrc = isPreviewGroup ? previewUrls.get(current) : src;
const showLeftOrRightSwitches = isPreviewGroup && previewGroupCount > 1;
const showOperationsProgress = isPreviewGroup && previewGroupCount >= 1;
const [lastWheelZoomDirection, setLastWheelZoomDirection] = useState({ wheelDirection: 0 });

const onAfterClose = () => {
Expand Down Expand Up @@ -302,7 +303,7 @@ const Preview: React.FC<PreviewProps> = props => {
{...restProps}
>
<ul className={`${prefixCls}-operations`}>
{showLeftOrRightSwitches && (
{showOperationsProgress && (
<li className={`${prefixCls}-operations-progress`}>
{countRender?.(currentPreviewIndex + 1, previewGroupCount) ??
`${currentPreviewIndex + 1} / ${previewGroupCount}`}
Expand All @@ -317,7 +318,7 @@ const Preview: React.FC<PreviewProps> = props => {
key={type}
>
{React.isValidElement(icon)
? React.cloneElement(icon, { className: iconClassName })
? React.cloneElement<{ className?: string }>(icon, { className: iconClassName })
: icon}
</li>
))}
Expand Down
5 changes: 5 additions & 0 deletions tests/__snapshots__/previewGroup.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ exports[`PreviewGroup With Controlled 1`] = `
<ul
class="rc-image-preview-operations"
>
<li
class="rc-image-preview-operations-progress"
>
1 / 1
</li>
<li
class="rc-image-preview-operations-operation"
/>
Expand Down

1 comment on commit 7acbbfb

@vercel
Copy link

@vercel vercel bot commented on 7acbbfb Aug 31, 2022

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.