From a6e620c975a70dee250b5a342625a676a4145302 Mon Sep 17 00:00:00 2001 From: TangLL Date: Thu, 22 Sep 2022 11:38:17 +0800 Subject: [PATCH 1/7] docs: defaultExpandedAll is not exist, should be defaultExpandAll (#37689) Co-authored-by: nocodeempire --- components/tree/index.en-US.md | 4 ++-- components/tree/index.zh-CN.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/tree/index.en-US.md b/components/tree/index.en-US.md index 77aaab480e..8daabb5167 100644 --- a/components/tree/index.en-US.md +++ b/components/tree/index.en-US.md @@ -109,9 +109,9 @@ Before `3.4.0`: The number of treeNodes can be very large, but when `checkable=t File icon realize by using switcherIcon. You can overwrite the style to hide it: -### Why defaultExpandedAll not working on ajax data? +### Why defaultExpandAll not working on ajax data? -`default` prefix prop only works when inited. So `defaultExpandedAll` has already executed when ajax load data. You can control `expandedKeys` or render Tree when data loaded to realize expanded all. +`default` prefix prop only works when inited. So `defaultExpandAll` has already executed when ajax load data. You can control `expandedKeys` or render Tree when data loaded to realize expanded all. ### Virtual scroll limitation diff --git a/components/tree/index.zh-CN.md b/components/tree/index.zh-CN.md index cccc34db83..c813be306b 100644 --- a/components/tree/index.zh-CN.md +++ b/components/tree/index.zh-CN.md @@ -110,9 +110,9 @@ cover: https://gw.alipayobjects.com/zos/alicdn/Xh-oWqg9k/Tree.svg 文件图标通过 switcherIcon 来实现,如果不需要你可以覆盖对应的样式: -### defaultExpandedAll 在异步加载数据时为何不生效? +### defaultExpandAll 在异步加载数据时为何不生效? -`default` 前缀属性只有在初始化时生效,因而异步加载数据时 `defaultExpandedAll` 已经执行完成。你可以通过受控 `expandedKeys` 或者在数据加载完成后渲染 Tree 来实现全部展开。 +`default` 前缀属性只有在初始化时生效,因而异步加载数据时 `defaultExpandAll` 已经执行完成。你可以通过受控 `expandedKeys` 或者在数据加载完成后渲染 Tree 来实现全部展开。 ### 虚拟滚动的限制 From af32d24b5f11b3e72b475302e94e11faa18b005f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Thu, 22 Sep 2022 16:15:00 +0800 Subject: [PATCH 2/7] chore: warning divider not support text (#37697) --- components/divider/__tests__/index.test.ts | 6 ------ components/divider/__tests__/index.test.tsx | 17 +++++++++++++++++ components/divider/index.tsx | 12 +++++++++++- 3 files changed, 28 insertions(+), 7 deletions(-) delete mode 100644 components/divider/__tests__/index.test.ts create mode 100644 components/divider/__tests__/index.test.tsx diff --git a/components/divider/__tests__/index.test.ts b/components/divider/__tests__/index.test.ts deleted file mode 100644 index 59763af9a4..0000000000 --- a/components/divider/__tests__/index.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import Divider from '..'; -import mountTest from '../../../tests/shared/mountTest'; - -describe('Divider', () => { - mountTest(Divider); -}); diff --git a/components/divider/__tests__/index.test.tsx b/components/divider/__tests__/index.test.tsx new file mode 100644 index 0000000000..0e581f43b2 --- /dev/null +++ b/components/divider/__tests__/index.test.tsx @@ -0,0 +1,17 @@ +import * as React from 'react'; +import { render } from '../../../tests/utils'; +import Divider from '..'; +import mountTest from '../../../tests/shared/mountTest'; + +describe('Divider', () => { + mountTest(Divider); + + it('not show children when vertical', () => { + const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + const { container } = render(Bamboo); + expect(container.querySelector('.ant-divider-inner-text')).toBeFalsy(); + + errSpy.mockRestore(); + }); +}); diff --git a/components/divider/index.tsx b/components/divider/index.tsx index 0cea83cb82..628f8acd0b 100644 --- a/components/divider/index.tsx +++ b/components/divider/index.tsx @@ -1,6 +1,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { ConfigContext } from '../config-provider'; +import warning from '../_util/warning'; export interface DividerProps { prefixCls?: string; @@ -53,9 +54,18 @@ const Divider: React.FC = props => { ...(hasCustomMarginRight && { marginRight: orientationMargin }), }; + // Warning children not work in vertical mode + if (process.env.NODE_ENV !== 'production') { + warning( + !children || type !== 'vertical', + 'Divider', + '`children` not working in `vertical` mode.', + ); + } + return (
- {children && ( + {children && type !== 'vertical' && ( {children} From 86865f6013737f9dbac33ffb600d107c276bb7e8 Mon Sep 17 00:00:00 2001 From: hugobarragon <35630927+hugobarragon@users.noreply.github.com> Date: Thu, 22 Sep 2022 11:35:39 +0100 Subject: [PATCH 3/7] fix PT typo from last mr on transfer locale (#37701) fix PT typo from last mr on transfer locale --- components/locale/pt_PT.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/locale/pt_PT.tsx b/components/locale/pt_PT.tsx index 9656c47c88..9fce8c76d2 100644 --- a/components/locale/pt_PT.tsx +++ b/components/locale/pt_PT.tsx @@ -31,7 +31,7 @@ const localeValues: Locale = { searchPlaceholder: 'Procurar...', itemUnit: 'item', itemsUnit: 'itens', - selectAll: 'Seleccionar Tudo', + selectAll: 'Selecionar tudo', selectInvert: 'Inverter a página actual', }, Upload: { From 35f2234fc344f9869eafcd13f4760f306afa1be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Thu, 22 Sep 2022 21:24:28 +0800 Subject: [PATCH 4/7] test: Refactor Form part test with jest fakeTimer to avoid CI failed (#37705) * test: rename form test file to tsx * test: All in ts * test: Use fake timer instead * test: for react 18 --- ...index.test.js.snap => index.test.tsx.snap} | 0 .../{index.test.js => index.test.tsx} | 121 ++++++++++-------- 2 files changed, 70 insertions(+), 51 deletions(-) rename components/form/__tests__/__snapshots__/{index.test.js.snap => index.test.tsx.snap} (100%) rename components/form/__tests__/{index.test.js => index.test.tsx} (92%) diff --git a/components/form/__tests__/__snapshots__/index.test.js.snap b/components/form/__tests__/__snapshots__/index.test.tsx.snap similarity index 100% rename from components/form/__tests__/__snapshots__/index.test.js.snap rename to components/form/__tests__/__snapshots__/index.test.tsx.snap diff --git a/components/form/__tests__/index.test.js b/components/form/__tests__/index.test.tsx similarity index 92% rename from components/form/__tests__/index.test.js rename to components/form/__tests__/index.test.tsx index c4263bbbcb..13a7232c8d 100644 --- a/components/form/__tests__/index.test.js +++ b/components/form/__tests__/index.test.tsx @@ -1,9 +1,9 @@ import { mount } from 'enzyme'; import React, { Component, useState } from 'react'; -import { act } from 'react-dom/test-utils'; import scrollIntoView from 'scroll-into-view-if-needed'; import classNames from 'classnames'; import Form from '..'; +import type { FormInstance } from '..'; import * as Util from '../util'; import Button from '../../button'; @@ -20,7 +20,7 @@ import TreeSelect from '../../tree-select'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; -import { fireEvent, render, sleep } from '../../../tests/utils'; +import { fireEvent, render, sleep, act } from '../../../tests/utils'; import ConfigProvider from '../../config-provider'; import Drawer from '../../drawer'; import zhCN from '../../locale/zh_CN'; @@ -38,10 +38,10 @@ describe('Form', () => { rtlTest(Form); rtlTest(Form.Item); - scrollIntoView.mockImplementation(() => {}); + (scrollIntoView as any).mockImplementation(() => {}); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); - async function change(container, index, value, executeMockTimer) { + async function change(container: Element, index: number, value: any, executeMockTimer: boolean) { fireEvent.change(container.querySelectorAll('input')[index], { target: { value }, }); @@ -59,7 +59,7 @@ describe('Form', () => { beforeEach(() => { jest.useRealTimers(); - scrollIntoView.mockReset(); + (scrollIntoView as any).mockReset(); }); afterEach(() => { @@ -68,7 +68,7 @@ describe('Form', () => { afterAll(() => { errorSpy.mockRestore(); - scrollIntoView.mockRestore(); + (scrollIntoView as any).mockRestore(); }); describe('noStyle Form.Item', () => { @@ -143,11 +143,11 @@ describe('Form', () => { const { container } = render(); await change(container, 0, '1', true); - expect(container.querySelector('.ant-form-item-explain').textContent).toEqual('aaa'); + expect(container.querySelector('.ant-form-item-explain')!.textContent).toEqual('aaa'); await change(container, 0, '2', true); - expect(container.querySelector('.ant-form-item-explain').textContent).toEqual('ccc'); + expect(container.querySelector('.ant-form-item-explain')!.textContent).toEqual('ccc'); await change(container, 0, '1', true); - expect(container.querySelector('.ant-form-item-explain').textContent).toEqual('aaa'); + expect(container.querySelector('.ant-form-item-explain')!.textContent).toEqual('aaa'); jest.useRealTimers(); }); @@ -356,9 +356,9 @@ describe('Form', () => { }); describe('scrollToField', () => { - function test(name, genForm) { + function test(name: string, genForm: () => { props: any; getForm: () => FormInstance }) { it(name, () => { - let callGetForm; + let callGetForm: () => FormInstance = undefined!; const Demo = () => { const { props, getForm } = genForm(); @@ -402,10 +402,10 @@ describe('Form', () => { // ref test('ref', () => { - let form; + let form: FormInstance; return { props: { - ref: instance => { + ref: (instance: FormInstance) => { form = instance; }, }, @@ -442,7 +442,7 @@ describe('Form', () => { it('Form.Item should support data-*、aria-* and custom attribute', () => { const wrapper = mount(
-