diff --git a/src/Table.tsx b/src/Table.tsx index a1ec7236f..df8a5f97c 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -246,9 +246,24 @@ function Table(props: TableProps mergedChildrenColumnName in record)) { + /* eslint-disable no-underscore-dangle */ + /** + * Fix https://github.com/ant-design/ant-design/issues/21154 + * This is a workaround to not to break current behavior. + * We can remove follow code after final release. + * + * To other developer: + * Do not use `__PARENT_RENDER_ICON__` in prod since we will remove this when refactor + */ + if ( + (props.expandable && + internalHooks === INTERNAL_HOOKS && + (props.expandable as any).__PARENT_RENDER_ICON__) || + mergedData.some(record => mergedChildrenColumnName in record) + ) { return 'nest'; } + /* eslint-enable */ return false; }, [!!expandedRowRender, mergedData]); diff --git a/tests/Internal.spec.js b/tests/Internal.spec.js new file mode 100644 index 000000000..c19c14373 --- /dev/null +++ b/tests/Internal.spec.js @@ -0,0 +1,23 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import Table from '../src'; +import { INTERNAL_HOOKS } from '../src/Table'; + +// All follow test is only for internal usage which should be removed when refactor +describe('Table.Internal', () => { + it('internal should pass `__PARENT_RENDER_ICON__` for expandable', () => { + const wrapper = mount( +
, + }} + />, + ); + + expect(wrapper.find('.expand-icon')).toHaveLength(1); + }); +});