Browse Source

fix: Fix the problem that className does not take effect in ImagePreview (#1659)

YyumeiZhang 2 years ago
parent
commit
667d32ccb6
1 changed files with 3 additions and 2 deletions
  1. 3 2
      packages/semi-ui/image/preview.tsx

+ 3 - 2
packages/semi-ui/image/preview.tsx

@@ -9,6 +9,7 @@ import { getUuidShort } from "@douyinfe/semi-foundation/utils/uuid";
 import { cssClasses } from "@douyinfe/semi-foundation/image/constants";
 import { isObject, isEqual } from "lodash";
 import "@douyinfe/semi-foundation/image/image.scss";
+import cls from "classnames";
 
 const prefixCls = cssClasses.PREFIX;
 
@@ -191,7 +192,7 @@ export default class Preview extends BaseComponent<PreviewProps, PreviewState> {
     };
 
     render() {
-        const { src, style, lazyLoad, ...restProps } = this.props;
+        const { src, className, style, lazyLoad, ...restProps } = this.props;
         const { currentIndex, visible } = this.state;
         const { srcListInChildren, newChildren, titles } = this.loopImageIndex();
         const srcArr = Array.isArray(src) ? src : (typeof src === "string" ? [src] : []);
@@ -210,7 +211,7 @@ export default class Preview extends BaseComponent<PreviewProps, PreviewState> {
                     handleVisibleChange: this.handleVisibleChange,
                 }}
             >
-                <div id={this.previewGroupId} style={style} className={`${prefixCls}-preview-group`}>
+                <div id={this.previewGroupId} style={style} className={cls(`${prefixCls}-preview-group`, className)}>
                     {newChildren}
                 </div>
                 <PreviewInner