File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -246,9 +246,24 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
246
246
if ( expandedRowRender ) {
247
247
return 'row' ;
248
248
}
249
- if ( mergedData . some ( record => mergedChildrenColumnName in record ) ) {
249
+ /* eslint-disable no-underscore-dangle */
250
+ /**
251
+ * Fix https://github.com/ant-design/ant-design/issues/21154
252
+ * This is a workaround to not to break current behavior.
253
+ * We can remove follow code after final release.
254
+ *
255
+ * To other developer:
256
+ * Do not use `__PARENT_RENDER_ICON__` in prod since we will remove this when refactor
257
+ */
258
+ if (
259
+ ( props . expandable &&
260
+ internalHooks === INTERNAL_HOOKS &&
261
+ ( props . expandable as any ) . __PARENT_RENDER_ICON__ ) ||
262
+ mergedData . some ( record => mergedChildrenColumnName in record )
263
+ ) {
250
264
return 'nest' ;
251
265
}
266
+ /* eslint-enable */
252
267
return false ;
253
268
} , [ ! ! expandedRowRender , mergedData ] ) ;
254
269
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { mount } from 'enzyme' ;
3
+ import Table from '../src' ;
4
+ import { INTERNAL_HOOKS } from '../src/Table' ;
5
+
6
+ // All follow test is only for internal usage which should be removed when refactor
7
+ describe ( 'Table.Internal' , ( ) => {
8
+ it ( 'internal should pass `__PARENT_RENDER_ICON__` for expandable' , ( ) => {
9
+ const wrapper = mount (
10
+ < Table
11
+ internalHooks = { INTERNAL_HOOKS }
12
+ columns = { [ { dataIndex : 'key' } ] }
13
+ data = { [ { key : 233 } ] }
14
+ expandable = { {
15
+ __PARENT_RENDER_ICON__ : true ,
16
+ expandIcon : ( ) => < div className = "expand-icon" /> ,
17
+ } }
18
+ /> ,
19
+ ) ;
20
+
21
+ expect ( wrapper . find ( '.expand-icon' ) ) . toHaveLength ( 1 ) ;
22
+ } ) ;
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments