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

Dev/v3.0 #8874

Merged
merged 5 commits into from
Nov 18, 2024
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
5 changes: 3 additions & 2 deletions packages/table/src/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ProCard from '@ant-design/pro-card';
import ProForm, { GridContext } from '@ant-design/pro-form';
import type { ParamsType } from '@ant-design/pro-provider';
import { ProConfigProvider, proTheme, useIntl } from '@ant-design/pro-provider';
import ProConfigContext, { ProConfigProvider, proTheme, useIntl } from '@ant-design/pro-provider';
import {
ErrorBoundary,
editableRowByKey,
Expand Down Expand Up @@ -1020,9 +1020,10 @@ const ProviderTableContainer = <
? React.Fragment
: props.ErrorBoundary || ErrorBoundary;

const context = useContext(ProConfigContext);
return (
<Container initValue={props}>
<ProConfigProvider valueTypeMap={ValueTypeToComponent} needDeps>
<ProConfigProvider valueTypeMap={{...context.valueTypeMap, ...ValueTypeToComponent}} needDeps>
<ErrorComponent>
<ProTable<DataType, Params, ValueType>
defaultClassName={`${getPrefixCls('pro-table')}`}
Expand Down
40 changes: 20 additions & 20 deletions tests/table/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1521,14 +1521,14 @@ describe('BasicTable', () => {
rowKey="key"
/>,
);

const input = await waitFor(() => html.baseElement.querySelector(
'.ant-pro-table-list-toolbar-search input',
)!)
await html.findByText('查 询');

act(() => {
fireEvent.change(
html.baseElement.querySelector(
'.ant-pro-table-list-toolbar-search input',
)!,
input,
{
target: {
value: 'name',
Expand All @@ -1541,9 +1541,7 @@ describe('BasicTable', () => {

act(() => {
fireEvent.keyDown(
html.baseElement.querySelector(
'.ant-pro-table-list-toolbar-search input',
)!,
input,
{ key: 'Enter', keyCode: 13 },
);
});
Expand All @@ -1554,9 +1552,7 @@ describe('BasicTable', () => {

act(() => {
fireEvent.change(
html.baseElement.querySelector(
'.ant-pro-table-list-toolbar-search input',
)!,
input,
{
target: {
value: 'name1',
Expand All @@ -1565,16 +1561,20 @@ describe('BasicTable', () => {
);
});

// await html.findByDisplayValue('name1');

// act(() => {
// fireEvent.keyDown(
// html.baseElement.querySelector(
// '.ant-pro-table-list-toolbar-search input',
// )!,
// { key: 'Enter', keyCode: 13 },
// );
// });
await html.findByDisplayValue('name1');
// 下一次keyDown前需要一次keyUp,除非是设置了长按
act(() => {
fireEvent.keyUp(
input,
{ key: 'Enter', keyCode: 13 },
);
});
act(() => {
fireEvent.keyDown(
input,
{ key: 'Enter', keyCode: 13 },
);
});

await waitFor(() => {
expect(fn).toHaveBeenCalledWith('name1');
Expand Down
1 change: 1 addition & 0 deletions tests/table/valueType.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ describe('BasicTable valueType', () => {
html.unmount();
});

// 使用valueTypeMap包裹protable后,这里的context不会使用导致单测失败
it('🎏 table valueType render support fieldProps', async () => {
const html = render(
<ProProvider.Provider
Expand Down
Loading