Skip to content

Commit

Permalink
Merge 722d6b5 into f921fdb
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanDC2 authored Apr 17, 2023
2 parents f921fdb + 722d6b5 commit 6e70327
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
11 changes: 5 additions & 6 deletions src/Body/ExpandedRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ function ExpandedRow(props: ExpandedRowProps) {
);
}

if (!expanded) {
return null;
}

return (
<Component
className={className}
style={{
display: expanded ? null : 'none',
}}
>
<Component className={className}>
<Cell component={cellComponent} prefixCls={prefixCls} colSpan={colSpan}>
{contentNode}
</Cell>
Expand Down
16 changes: 7 additions & 9 deletions tests/ExpandRow.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { mount } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { resetWarned } from 'rc-util/lib/warning';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import { resetWarned } from 'rc-util/lib/warning';
import React from 'react';
import { act } from 'react-dom/test-utils';
import Table from '../src';

describe('Table.Expand', () => {
Expand Down Expand Up @@ -393,10 +393,8 @@ describe('Table.Expand', () => {
expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy();

wrapper.setProps({ expandedRowKeys: [1] });
expect(wrapper.find('tbody tr')).toHaveLength(4);
expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy();
expect(wrapper.find('tbody tr').at(1).props().style.display).toEqual('none');
expect(wrapper.find('tbody tr').at(3).hasClass('rc-table-expanded-row')).toBeTruthy();
expect(wrapper.find('tbody tr')).toHaveLength(3);
expect(wrapper.find('tbody tr').at(2).hasClass('rc-table-expanded-row')).toBeTruthy();
});

it('renders expend row class correctly', () => {
Expand Down Expand Up @@ -551,11 +549,11 @@ describe('Table.Expand', () => {
wrapper.find('.custom-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
expect(onExpand).toHaveBeenCalledTimes(1);
expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('');
expect(wrapper.find('.rc-table-expanded-row').length).toBe(2);
wrapper.find('.custom-expand-icon').first().simulate('click');
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
expect(onExpand).toHaveBeenCalledTimes(2);
expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('none');
expect(wrapper.find('.rc-table-expanded-row').length).toBe(1);
});

// https://github.com/ant-design/ant-design/issues/23894
Expand Down

0 comments on commit 6e70327

Please sign in to comment.