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 =
3636 | 'style'
3737 | 'direction'
3838 | 'notFoundContent'
39- | 'disabled' ;
39+ | 'disabled'
40+ | 'optionRender' ;
4041
4142export type PanelProps <
4243 OptionType extends DefaultOptionType = DefaultOptionType ,
@@ -70,6 +71,7 @@ export default function Panel<
7071 direction,
7172 notFoundContent = 'Not Found' ,
7273 disabled,
74+ optionRender,
7375 } = props as Pick < InternalCascaderProps , PickType > ;
7476
7577 // ======================== Multiple ========================
@@ -159,6 +161,7 @@ export default function Panel<
159161 expandIcon,
160162 loadingIcon,
161163 popupMenuColumnStyle : undefined ,
164+ optionRender
162165 } ) ,
163166 [
164167 mergedOptions ,
@@ -172,6 +175,7 @@ export default function Panel<
172175 expandTrigger ,
173176 expandIcon ,
174177 loadingIcon ,
178+ optionRender ,
175179 ] ,
176180 ) ;
177181
Original file line number Diff line number Diff line change @@ -110,4 +110,25 @@ describe('Cascader.Panel', () => {
110110 fireEvent . click ( selectOption ) ;
111111 expect ( onChange ) . not . toHaveBeenCalled ( ) ;
112112 } ) ;
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+ } ) ;
113134} ) ;
You can’t perform that action at this time.
0 commit comments