File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
119
119
cover,
120
120
classNames : previewClassNames = { } ,
121
121
styles : previewStyles = { } ,
122
+ rootClassName : previewRootClassName ,
122
123
...restProps
123
124
} : PreviewConfig = preview && typeof preview === 'object' ? preview : { } ;
124
125
@@ -262,7 +263,7 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
262
263
imgCommonProps = { imgCommonProps }
263
264
classNames = { previewClassNames }
264
265
styles = { previewStyles }
265
- rootClassName = { rootClassName }
266
+ rootClassName = { classnames ( previewRootClassName , rootClassName ) }
266
267
{ ...restProps }
267
268
/>
268
269
) }
Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ export type ToolbarRenderInfoType = {
68
68
69
69
export interface InternalPreviewConfig {
70
70
// Semantic
71
+ /** Better to use `classNames.root` instead */
72
+ rootClassName ?: string ;
71
73
classNames ?: Partial < Record < InternalPreviewSemanticName , string > > ;
72
74
styles ?: Partial < Record < InternalPreviewSemanticName , React . CSSProperties > > ;
73
75
@@ -108,7 +110,6 @@ export interface InternalPreviewConfig {
108
110
export interface PreviewProps extends InternalPreviewConfig {
109
111
// Misc
110
112
prefixCls : string ;
111
- rootClassName ?: string ;
112
113
113
114
// Origin image Info
114
115
imageInfo ?: {
Original file line number Diff line number Diff line change @@ -643,7 +643,7 @@ describe('Preview', () => {
643
643
644
644
it ( 'Customize preview props' , ( ) => {
645
645
const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' ;
646
- const { container } = render (
646
+ render (
647
647
< Image
648
648
src = { src }
649
649
preview = { {
@@ -712,6 +712,21 @@ describe('Preview', () => {
712
712
expect ( document . querySelectorAll ( '.custom-className' ) ) . toHaveLength ( 2 ) ;
713
713
} ) ;
714
714
715
+ it ( 'preview.rootClassName should be correct' , ( ) => {
716
+ const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' ;
717
+ render (
718
+ < Image
719
+ src = { src }
720
+ preview = { {
721
+ open : true ,
722
+ rootClassName : 'custom-className' ,
723
+ } }
724
+ /> ,
725
+ ) ;
726
+
727
+ expect ( document . querySelector ( '.rc-image-preview.custom-className' ) ) . toBeTruthy ( ) ;
728
+ } ) ;
729
+
715
730
it ( 'if async src set should be correct' , ( ) => {
716
731
const src =
717
732
'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*P0S-QIRUbsUAAAAAAAAAAABkARQnAQ' ;
You can’t perform that action at this time.
0 commit comments