Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Table expanded icon pass internal status #413

Merged
merged 2 commits into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,24 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
if (expandedRowRender) {
return 'row';
}
if (mergedData.some(record => 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]);

Expand Down
23 changes: 23 additions & 0 deletions tests/Internal.spec.js
Original file line number Diff line number Diff line change
@@ -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(
<Table
internalHooks={INTERNAL_HOOKS}
columns={[{ dataIndex: 'key' }]}
data={[{ key: 233 }]}
expandable={{
__PARENT_RENDER_ICON__: true,
expandIcon: () => <div className="expand-icon" />,
}}
/>,
);

expect(wrapper.find('.expand-icon')).toHaveLength(1);
});
});