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 => {
119119 cover,
120120 classNames : previewClassNames = { } ,
121121 styles : previewStyles = { } ,
122+ rootClassName : previewRootClassName ,
122123 ...restProps
123124 } : PreviewConfig = preview && typeof preview === 'object' ? preview : { } ;
124125
@@ -262,7 +263,7 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
262263 imgCommonProps = { imgCommonProps }
263264 classNames = { previewClassNames }
264265 styles = { previewStyles }
265- rootClassName = { rootClassName }
266+ rootClassName = { classnames ( previewRootClassName , rootClassName ) }
266267 { ...restProps }
267268 />
268269 ) }
Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ export type ToolbarRenderInfoType = {
6868
6969export interface InternalPreviewConfig {
7070 // Semantic
71+ /** Better to use `classNames.root` instead */
72+ rootClassName ?: string ;
7173 classNames ?: Partial < Record < InternalPreviewSemanticName , string > > ;
7274 styles ?: Partial < Record < InternalPreviewSemanticName , React . CSSProperties > > ;
7375
@@ -108,7 +110,6 @@ export interface InternalPreviewConfig {
108110export interface PreviewProps extends InternalPreviewConfig {
109111 // Misc
110112 prefixCls : string ;
111- rootClassName ?: string ;
112113
113114 // Origin image Info
114115 imageInfo ?: {
Original file line number Diff line number Diff line change @@ -643,7 +643,7 @@ describe('Preview', () => {
643643
644644 it ( 'Customize preview props' , ( ) => {
645645 const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' ;
646- const { container } = render (
646+ render (
647647 < Image
648648 src = { src }
649649 preview = { {
@@ -712,6 +712,21 @@ describe('Preview', () => {
712712 expect ( document . querySelectorAll ( '.custom-className' ) ) . toHaveLength ( 2 ) ;
713713 } ) ;
714714
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+
715730 it ( 'if async src set should be correct' , ( ) => {
716731 const src =
717732 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*P0S-QIRUbsUAAAAAAAAAAABkARQnAQ' ;
You can’t perform that action at this time.
0 commit comments