File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ export type PickType =
36
36
| 'style'
37
37
| 'direction'
38
38
| 'notFoundContent'
39
- | 'disabled' ;
39
+ | 'disabled'
40
+ | 'optionRender' ;
40
41
41
42
export type PanelProps <
42
43
OptionType extends DefaultOptionType = DefaultOptionType ,
@@ -70,6 +71,7 @@ export default function Panel<
70
71
direction,
71
72
notFoundContent = 'Not Found' ,
72
73
disabled,
74
+ optionRender,
73
75
} = props as Pick < InternalCascaderProps , PickType > ;
74
76
75
77
// ======================== Multiple ========================
@@ -159,6 +161,7 @@ export default function Panel<
159
161
expandIcon,
160
162
loadingIcon,
161
163
popupMenuColumnStyle : undefined ,
164
+ optionRender
162
165
} ) ,
163
166
[
164
167
mergedOptions ,
@@ -172,6 +175,7 @@ export default function Panel<
172
175
expandTrigger ,
173
176
expandIcon ,
174
177
loadingIcon ,
178
+ optionRender ,
175
179
] ,
176
180
) ;
177
181
Original file line number Diff line number Diff line change @@ -110,4 +110,25 @@ describe('Cascader.Panel', () => {
110
110
fireEvent . click ( selectOption ) ;
111
111
expect ( onChange ) . not . toHaveBeenCalled ( ) ;
112
112
} ) ;
113
+
114
+ it ( 'Should optionRender work in Panel' , ( ) => {
115
+ const { container, rerender } = render (
116
+ < Cascader . Panel
117
+ options = { [ { label : 'bamboo' , value : 'bamboo' } ] }
118
+ optionRender = { option => `${ option . label } - test` }
119
+ /> ,
120
+ ) ;
121
+ expect ( container . querySelector ( '.rc-cascader-menu-item-content' ) ?. innerHTML ) . toEqual (
122
+ 'bamboo - test' ,
123
+ ) ;
124
+ rerender (
125
+ < Cascader . Panel
126
+ options = { [ { label : 'bamboo' , disabled : true , value : 'bamboo' } ] }
127
+ optionRender = { option => JSON . stringify ( option ) }
128
+ /> ,
129
+ ) ;
130
+ expect ( container . querySelector ( '.rc-cascader-menu-item-content' ) ?. innerHTML ) . toEqual (
131
+ '{"label":"bamboo","disabled":true,"value":"bamboo"}' ,
132
+ ) ;
133
+ } ) ;
113
134
} ) ;
You can’t perform that action at this time.
0 commit comments