From 7503caeb1859fb45ec2f4a126da1ad5b51f69aff Mon Sep 17 00:00:00 2001 From: chrismorison-wt <104949709+chrismorison-wt@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:52:58 +1300 Subject: [PATCH 01/23] docs: fix docs for Alert closeIcon prop. Fixes #38123 (#38124) --- components/alert/index.en-US.md | 2 +- components/alert/index.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/alert/index.en-US.md b/components/alert/index.en-US.md index 8b8992206b..982057c3cd 100644 --- a/components/alert/index.en-US.md +++ b/components/alert/index.en-US.md @@ -21,7 +21,7 @@ Alert component for feedback. | banner | Whether to show as banner | boolean | false | | | closable | Whether Alert can be closed | boolean | - | | | closeText | Close text to show | ReactNode | - | | -| closeIcon | Custom close icon | ReactNode | `` | 4.17.0 | +| closeIcon | Custom close icon | ReactNode | `` | 4.18.0 | | description | Additional content of Alert | ReactNode | - | | | icon | Custom icon, effective when `showIcon` is true | ReactNode | - | | | message | Content of Alert | ReactNode | - | | diff --git a/components/alert/index.zh-CN.md b/components/alert/index.zh-CN.md index 8946f08330..ee0a63de85 100644 --- a/components/alert/index.zh-CN.md +++ b/components/alert/index.zh-CN.md @@ -22,7 +22,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/8emPa3fjl/Alert.svg | banner | 是否用作顶部公告 | boolean | false | | | closable | 默认不显示关闭按钮 | boolean | - | | | closeText | 自定义关闭按钮 | ReactNode | - | | -| closeIcon | 自定义关闭 Icon | ReactNode | `` | 4.17.0 | +| closeIcon | 自定义关闭 Icon | ReactNode | `` | 4.18.0 | | description | 警告提示的辅助性文字介绍 | ReactNode | - | | | icon | 自定义图标,`showIcon` 为 true 时有效 | ReactNode | - | | | message | 警告提示内容 | ReactNode | - | | From 769cb3c79ad94fc175cf214d188d1eff8b7a9376 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Thu, 20 Oct 2022 16:37:35 +0800 Subject: [PATCH 02/23] style: remove repeate method (#38133) * style: remove repeate method * fix: del break --- components/_util/reactNode.ts | 2 +- components/button/button.tsx | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/components/_util/reactNode.ts b/components/_util/reactNode.ts index 38e23ee422..8e5b73c016 100644 --- a/components/_util/reactNode.ts +++ b/components/_util/reactNode.ts @@ -2,7 +2,7 @@ import * as React from 'react'; export const { isValidElement } = React; -export function isFragment(child: React.ReactElement): boolean { +export function isFragment(child: any): boolean { return child && isValidElement(child) && child.type === React.Fragment; } diff --git a/components/button/button.tsx b/components/button/button.tsx index 469383a145..fd1a4ef8dc 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -7,7 +7,7 @@ import { ConfigContext } from '../config-provider'; import DisabledContext from '../config-provider/DisabledContext'; import type { SizeType } from '../config-provider/SizeContext'; import SizeContext from '../config-provider/SizeContext'; -import { cloneElement } from '../_util/reactNode'; +import { cloneElement, isFragment } from '../_util/reactNode'; import { tuple } from '../_util/type'; import warning from '../_util/warning'; import Wave from '../_util/wave'; @@ -24,10 +24,6 @@ function isUnBorderedButtonType(type: ButtonType | undefined) { return type === 'text' || type === 'link'; } -function isReactFragment(node: React.ReactNode) { - return React.isValidElement(node) && node.type === React.Fragment; -} - // Insert one space between two chinese characters automatically. function insertSpace(child: React.ReactElement | string | number, needInserted: boolean) { // Check the child if is undefined or null. @@ -49,7 +45,7 @@ function insertSpace(child: React.ReactElement | string | number, needInserted: if (typeof child === 'string') { return isTwoCNChar(child) ? {child.split('').join(SPACE)} : {child}; } - if (isReactFragment(child)) { + if (isFragment(child)) { return {child}; } return child; From 3eff12dd69a83be3eb941f3be65c3d5d616afa56 Mon Sep 17 00:00:00 2001 From: zty Date: Thu, 20 Oct 2022 18:05:29 +0800 Subject: [PATCH 03/23] docs: fix demo code (#38136) * docs: fix demo code * docs: fix demo code * docs: fix demo code --- docs/react/practical-projects.en-US.md | 25 ++++++++++++------------- docs/react/practical-projects.zh-CN.md | 16 ++++++---------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/docs/react/practical-projects.en-US.md b/docs/react/practical-projects.en-US.md index b94699ad91..08911ea7da 100644 --- a/docs/react/practical-projects.en-US.md +++ b/docs/react/practical-projects.en-US.md @@ -68,10 +68,13 @@ Let's create a `ProductList` component that we can use in multiple places to sho Create `src/components/ProductList.tsx` by typing: -```js +```tsx import { Table, Popconfirm, Button } from 'antd'; -const ProductList = ({ onDelete, products }) => { +const ProductList: React.FC<{ products: { name: string }[]; onDelete: (id: string) => void }> = ({ + onDelete, + products, +}) => { const columns = [ { title: 'Name', @@ -112,16 +115,12 @@ export function queryProductList() { export function queryProductList() { return new Promise(resolve => { setTimeout(() => { - resolve([ - { - id: 1, - name: 'dva', - }, - { - id: 2, - name: 'antd', - }, - ]); + resolve({ + data: [ + { id: 1, name: 'dva' }, + { id: 2, name: 'antd' }, + ], + }); }, 2000); }); } @@ -134,7 +133,7 @@ import { useRequest } from 'umi'; import { queryProductList } from '@/services/product'; export default function useProductList(params: { pageSize: number; current: number }) { - const msg = useRequest(() => queryUserList(params)); + const msg = useRequest(() => queryProductList(params)); const deleteProducts = async (id: string) => { try { diff --git a/docs/react/practical-projects.zh-CN.md b/docs/react/practical-projects.zh-CN.md index 4751ce6ee9..dc15c52a11 100644 --- a/docs/react/practical-projects.zh-CN.md +++ b/docs/react/practical-projects.zh-CN.md @@ -109,16 +109,12 @@ export function queryProductList() { export function queryProductList() { return new Promise(resolve => { setTimeout(() => { - resolve([ - { - id: 1, - name: 'dva', - }, - { - id: 2, - name: 'antd', - }, - ]); + resolve({ + data: [ + { id: 1, name: 'dva' }, + { id: 2, name: 'antd' }, + ], + }); }, 2000); }); } From 3d33c340103152c7af9157d0023dd1c7db9cab62 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Fri, 21 Oct 2022 11:45:55 +0800 Subject: [PATCH 04/23] chore: use includes instead indexOf (#38139) * chore: use includes instead indexOf * fix: fix --- components/_util/wave.tsx | 4 ++-- components/badge/utils.tsx | 2 +- components/checkbox/Checkbox.tsx | 2 +- components/checkbox/Group.tsx | 4 ++-- components/form/util.ts | 2 +- components/progress/progress.tsx | 4 ++-- components/statistic/utils.tsx | 2 +- components/table/Table.tsx | 4 ++-- components/transfer/ListBody.tsx | 4 ++-- components/transfer/index.tsx | 12 ++++++------ components/transfer/list.tsx | 4 ++-- components/tree/utils/dictUtil.ts | 7 +------ components/typography/Title.tsx | 2 +- components/typography/__tests__/index.test.tsx | 10 +++++----- scripts/generate-authors.js | 2 +- site/theme/template/Color/Palette.jsx | 2 +- site/theme/template/Content/index.jsx | 2 +- 17 files changed, 32 insertions(+), 37 deletions(-) diff --git a/components/_util/wave.tsx b/components/_util/wave.tsx index 0569966e55..172c35f2ff 100644 --- a/components/_util/wave.tsx +++ b/components/_util/wave.tsx @@ -87,7 +87,7 @@ class Wave extends React.Component { onClick = (node: HTMLElement, waveColor: string) => { const { insertExtraNode, disabled } = this.props; - if (disabled || !node || isHidden(node) || node.className.indexOf('-leave') >= 0) { + if (disabled || !node || isHidden(node) || node.className.includes('-leave')) { return; } @@ -163,7 +163,7 @@ class Wave extends React.Component { !node || !node.getAttribute || node.getAttribute('disabled') || - node.className.indexOf('disabled') >= 0 + node.className.includes('disabled') ) { return; } diff --git a/components/badge/utils.tsx b/components/badge/utils.tsx index ada1c6580c..2c9a500e88 100644 --- a/components/badge/utils.tsx +++ b/components/badge/utils.tsx @@ -2,5 +2,5 @@ import { PresetColorTypes } from '../_util/colors'; // eslint-disable-next-line import/prefer-default-export export function isPresetColor(color?: string): boolean { - return (PresetColorTypes as any[]).indexOf(color) !== -1; + return (PresetColorTypes as any[]).includes(color); } diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index bed9a7e975..03449860d0 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -102,7 +102,7 @@ const InternalCheckbox: React.ForwardRefRenderFunction registeredValues.indexOf(val) !== -1) + .filter(val => registeredValues.includes(val)) .sort((a, b) => { const indexA = opts.findIndex(opt => opt.value === a); const indexB = opts.findIndex(opt => opt.value === b); @@ -122,7 +122,7 @@ const InternalCheckboxGroup: React.ForwardRefRenderFunction= 0; + const isIllegalName = formItemNameBlackList.includes(mergedId); return isIllegalName ? `${defaultItemNamePrefixCls}_${mergedId}` : mergedId; } diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index e0bb06a3e9..3d995b9440 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -75,7 +75,7 @@ const Progress: React.FC = (props: ProgressProps) => { function getProgressStatus() { const { status } = props; - if (ProgressStatuses.indexOf(status!) < 0 && getPercentNumber() >= 100) { + if (!ProgressStatuses.includes(status!) && getPercentNumber() >= 100) { return 'success'; } return status || 'normal'; @@ -119,7 +119,7 @@ const Progress: React.FC = (props: ProgressProps) => { const strokeColorNotArray = Array.isArray(strokeColor) ? strokeColor[0] : strokeColor; const strokeColorNotGradient = typeof strokeColor === 'string' || Array.isArray(strokeColor) ? strokeColor : undefined; - let progress; + let progress: React.ReactNode; // Render progress shape if (type === 'line') { progress = steps ? ( diff --git a/components/statistic/utils.tsx b/components/statistic/utils.tsx index 600abbe27f..91027740f4 100644 --- a/components/statistic/utils.tsx +++ b/components/statistic/utils.tsx @@ -41,7 +41,7 @@ export function formatTimeStr(duration: number, format: string) { const templateText = format.replace(escapeRegex, '[]'); const replacedText = timeUnits.reduce((current, [name, unit]) => { - if (current.indexOf(name) !== -1) { + if (current.includes(name)) { const value = Math.floor(leftDuration / unit); leftDuration -= value * unit; return current.replace(new RegExp(`${name}+`, 'g'), (match: string) => { diff --git a/components/table/Table.tsx b/components/table/Table.tsx index d08d1a5fb2..1c378c5ab7 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -482,8 +482,8 @@ function InternalTable( const defaultPosition = direction === 'rtl' ? 'left' : 'right'; const { position } = mergedPagination; if (position !== null && Array.isArray(position)) { - const topPos = position.find(p => p.indexOf('top') !== -1); - const bottomPos = position.find(p => p.indexOf('bottom') !== -1); + const topPos = position.find(p => p.includes('top')); + const bottomPos = position.find(p => p.includes('bottom')); const isDisable = position.every(p => `${p}` === 'none'); if (!topPos && !bottomPos && !isDisable) { bottomPaginationNode = renderPagination(defaultPosition); diff --git a/components/transfer/ListBody.tsx b/components/transfer/ListBody.tsx index d111f30f2b..e5f57703c3 100644 --- a/components/transfer/ListBody.tsx +++ b/components/transfer/ListBody.tsx @@ -71,7 +71,7 @@ class ListBody extends React.Component< onItemSelect = (item: RecordType) => { const { onItemSelect, selectedKeys } = this.props; - const checked = selectedKeys.indexOf(item.key) >= 0; + const checked = selectedKeys.includes(item.key); onItemSelect(item.key, !checked); }; @@ -144,7 +144,7 @@ class ListBody extends React.Component< > {this.getItems().map(({ renderedEl, renderedText, item }: RenderedItem) => { const { disabled } = item; - const checked = selectedKeys.indexOf(item.key) >= 0; + const checked = selectedKeys.includes(item.key); return ( extends React.Com const { selectedKeys = [], targetKeys = [] } = props; this.state = { - sourceSelectedKeys: selectedKeys.filter(key => targetKeys.indexOf(key) === -1), - targetSelectedKeys: selectedKeys.filter(key => targetKeys.indexOf(key) > -1), + sourceSelectedKeys: selectedKeys.filter(key => !targetKeys.includes(key)), + targetSelectedKeys: selectedKeys.filter(key => targetKeys.includes(key)), }; } @@ -198,7 +198,7 @@ class Transfer extends React.Com const newTargetKeys = direction === 'right' ? newMoveKeys.concat(targetKeys) - : targetKeys.filter(targetKey => newMoveKeys.indexOf(targetKey) === -1); + : targetKeys.filter(targetKey => !newMoveKeys.includes(targetKey)); // empty checked keys const oppositeDirection = direction === 'right' ? 'left' : 'right'; @@ -214,13 +214,13 @@ class Transfer extends React.Com onItemSelectAll = (direction: TransferDirection, selectedKeys: string[], checkAll: boolean) => { this.setStateKeys(direction, prevKeys => { - let mergedCheckedKeys = []; + let mergedCheckedKeys: string[] = []; if (checkAll) { // Merge current keys with origin key - mergedCheckedKeys = Array.from(new Set([...prevKeys, ...selectedKeys])); + mergedCheckedKeys = Array.from(new Set([...prevKeys, ...selectedKeys])); } else { // Remove current keys from origin keys - mergedCheckedKeys = prevKeys.filter((key: string) => selectedKeys.indexOf(key) === -1); + mergedCheckedKeys = prevKeys.filter(key => !selectedKeys.includes(key)); } this.handleSelectChange(direction, mergedCheckedKeys); diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index 00f9b5c685..a6e132b64d 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -109,7 +109,7 @@ export default class TransferList< if (checkedKeys.length === 0) { return 'none'; } - if (filteredItems.every(item => checkedKeys.indexOf(item.key) >= 0 || !!item.disabled)) { + if (filteredItems.every(item => checkedKeys.includes(item.key) || !!item.disabled)) { return 'all'; } return 'part'; @@ -161,7 +161,7 @@ export default class TransferList< if (filterOption) { return filterOption(filterValue, item); } - return text.indexOf(filterValue) >= 0; + return text.includes(filterValue); }; // =============================== Render =============================== diff --git a/components/tree/utils/dictUtil.ts b/components/tree/utils/dictUtil.ts index f1411c6a7e..bc6cfa0343 100644 --- a/components/tree/utils/dictUtil.ts +++ b/components/tree/utils/dictUtil.ts @@ -65,12 +65,7 @@ export function calcRangeKeys({ // Append selection keys.push(key); } - - if (expandedKeys.indexOf(key) === -1) { - return false; - } - - return true; + return expandedKeys.includes(key); }); return keys; diff --git a/components/typography/Title.tsx b/components/typography/Title.tsx index 2e0ab33b1d..1cd1f84246 100644 --- a/components/typography/Title.tsx +++ b/components/typography/Title.tsx @@ -19,7 +19,7 @@ const Title = React.forwardRef((props, ref) => { const { level = 1, ...restProps } = props; let component: keyof JSX.IntrinsicElements; - if (TITLE_ELE_LIST.indexOf(level) !== -1) { + if (TITLE_ELE_LIST.includes(level)) { component = `h${level}`; } else { warning( diff --git a/components/typography/__tests__/index.test.tsx b/components/typography/__tests__/index.test.tsx index 703efec890..ab2f767f24 100644 --- a/components/typography/__tests__/index.test.tsx +++ b/components/typography/__tests__/index.test.tsx @@ -262,14 +262,14 @@ describe('Typography', () => { , ); - if (triggerType === undefined || triggerType.indexOf('icon') !== -1) { + if (triggerType === undefined || triggerType.includes('icon')) { if (icon) { expect(wrapper.querySelectorAll('.anticon-highlight').length).toBeGreaterThan(0); } else { expect(wrapper.querySelectorAll('.anticon-edit').length).toBeGreaterThan(0); } - if (triggerType === undefined || triggerType.indexOf('text') === -1) { + if (triggerType === undefined || !triggerType.includes('text')) { fireEvent.click(wrapper.firstChild!); expect(onStart).not.toHaveBeenCalled(); } @@ -295,15 +295,15 @@ describe('Typography', () => { fireEvent.click(wrapper.querySelectorAll('.ant-typography-edit')[0]); expect(onStart).toHaveBeenCalled(); - if (triggerType !== undefined && triggerType.indexOf('text') !== -1) { + if (triggerType !== undefined && triggerType.includes('text')) { fireEvent.keyDown(wrapper.querySelector('textarea')!, { keyCode: KeyCode.ESC }); fireEvent.keyUp(wrapper.querySelector('textarea')!, { keyCode: KeyCode.ESC }); expect(onChange).not.toHaveBeenCalled(); } } - if (triggerType !== undefined && triggerType.indexOf('text') !== -1) { - if (triggerType.indexOf('icon') === -1) { + if (triggerType !== undefined && triggerType.includes('text')) { + if (!triggerType.includes('icon')) { expect(wrapper.querySelectorAll('.anticon-highlight').length).toBe(0); expect(wrapper.querySelectorAll('.anticon-edit').length).toBe(0); } diff --git a/scripts/generate-authors.js b/scripts/generate-authors.js index 02ede750bd..716ecf8637 100644 --- a/scripts/generate-authors.js +++ b/scripts/generate-authors.js @@ -21,7 +21,7 @@ async function execute() { logs = _.remove(logs, ({ author_email: email }) => { for (let i = 0; i < excludes.length; i++) { const item = excludes[i]; - if (email.indexOf(item) !== -1) { + if (email.includes(item)) { return false; } } diff --git a/site/theme/template/Color/Palette.jsx b/site/theme/template/Color/Palette.jsx index f7bbb6ac49..cfff5d67ca 100644 --- a/site/theme/template/Color/Palette.jsx +++ b/site/theme/template/Color/Palette.jsx @@ -19,7 +19,7 @@ export default class Palette extends React.Component { this.hexColors = {}; Object.keys(this.colorNodes).forEach(key => { const computedColor = getComputedStyle(this.colorNodes[key])['background-color']; - if (computedColor.indexOf('rgba') >= 0) { + if (computedColor.includes('rgba')) { this.hexColors[key] = computedColor; } else { this.hexColors[key] = rgbToHex(computedColor); diff --git a/site/theme/template/Content/index.jsx b/site/theme/template/Content/index.jsx index b5129b4215..8e5a7b3c04 100644 --- a/site/theme/template/Content/index.jsx +++ b/site/theme/template/Content/index.jsx @@ -3,7 +3,7 @@ import MainContent from './MainContent'; import * as utils from '../utils'; function isChangelog(pathname) { - return pathname.indexOf('changelog') >= 0; + return pathname.includes('changelog'); } export default collect(async nextProps => { From be1a51e5fc7aeba4a6bcd8ed2748bf90080507ad Mon Sep 17 00:00:00 2001 From: hms181231 Date: Fri, 21 Oct 2022 15:06:11 +0800 Subject: [PATCH 05/23] test: Update form test case (#38143) --- components/form/__tests__/list.test.tsx | 117 +++++++++++++----------- 1 file changed, 65 insertions(+), 52 deletions(-) diff --git a/components/form/__tests__/list.test.tsx b/components/form/__tests__/list.test.tsx index 0010d782f7..671ada9994 100644 --- a/components/form/__tests__/list.test.tsx +++ b/components/form/__tests__/list.test.tsx @@ -1,27 +1,59 @@ import React from 'react'; import type { FormListFieldData, FormListOperation } from '..'; import Form from '..'; -import { fireEvent, render, sleep, act } from '../../../tests/utils'; +import { fireEvent, render, waitFakeTimer } from '../../../tests/utils'; import Button from '../../button'; import Input from '../../input'; describe('Form.List', () => { - const change = async ( - wrapper: ReturnType['container'], - index: number, + // const change = async ( + // wrapper: ReturnType['container'], + // index: number, + // value: string, + // ) => { + // fireEvent.change(wrapper.getElementsByClassName('ant-input')?.[index], { target: { value } }); + // await sleep(); + // }; + + const changeValue = async ( + input: HTMLElement | null | number, value: string, + advTimer = 1000, ) => { - fireEvent.change(wrapper.getElementsByClassName('ant-input')?.[index], { target: { value } }); - await sleep(); + let element: HTMLElement; + + if (typeof input === 'number') { + element = document.querySelectorAll('input')[input]; + } + + expect(element!).toBeTruthy(); + + fireEvent.change(element!, { + target: { + value, + }, + }); + + if (advTimer) { + await waitFakeTimer(advTimer / 20); + } }; + beforeEach(() => { + document.body.innerHTML = ''; + jest.useFakeTimers(); + }); + + afterAll(() => { + jest.clearAllTimers(); + jest.useRealTimers(); + }); + const testList = ( name: string, renderField: (value: FormListFieldData) => React.ReactNode, ): void => { it(name, async () => { - jest.useFakeTimers(); - const { container } = render(
@@ -39,39 +71,31 @@ describe('Form.List', () => { , ); - function operate(className: string) { + async function operate(className: string) { fireEvent.click(container.querySelector(className)!); - act(() => { - jest.runAllTimers(); - }); + await waitFakeTimer(); } - operate('.add'); - expect(container.getElementsByClassName('ant-input').length).toBe(1); + await operate('.add'); + expect(container.querySelectorAll('.ant-input').length).toBe(1); - operate('.add'); - expect(container.getElementsByClassName('ant-input').length).toBe(2); + await operate('.add'); + expect(container.querySelectorAll('.ant-input').length).toBe(2); - operate('.add'); - expect(container.getElementsByClassName('ant-input').length).toBe(3); + await operate('.add'); + expect(container.querySelectorAll('.ant-input').length).toBe(3); - await change(container, 2, ''); - for (let i = 0; i < 10; i += 1) { - act(() => { - jest.runAllTimers(); - }); - } - expect(container.getElementsByClassName('ant-form-item-explain').length).toBe(1); + await changeValue(2, ''); - operate('.remove-0'); - expect(container.getElementsByClassName('ant-input').length).toBe(2); - expect(container.getElementsByClassName('ant-form-item-explain').length).toBe(1); + expect(container.querySelectorAll('.ant-form-item-explain').length).toBe(1); - operate('.remove-1'); - expect(container.getElementsByClassName('ant-input').length).toBe(1); - expect(container.getElementsByClassName('ant-form-item-explain').length).toBe(0); + await operate('.remove-0'); + expect(container.querySelectorAll('.ant-input').length).toBe(2); + expect(container.querySelectorAll('.ant-form-item-explain').length).toBe(1); - jest.useRealTimers(); + await operate('.remove-1'); + expect(container.querySelectorAll('.ant-input').length).toBe(1); + expect(container.querySelectorAll('.ant-form-item-explain').length).toBe(0); }); }; @@ -131,28 +155,26 @@ describe('Form.List', () => { ); await click(container, '.add'); - await change(container, 0, 'input1'); + await changeValue(0, 'input1'); fireEvent.submit(container.querySelector('form')!); - await sleep(); + await waitFakeTimer(); expect(onFinish).toHaveBeenLastCalledWith({ list: ['input1'] }); await click(container, '.add'); - await change(container, 1, 'input2'); + await changeValue(1, 'input2'); await click(container, '.add'); - await change(container, 2, 'input3'); + await changeValue(2, 'input3'); fireEvent.submit(container.querySelector('form')!); - await sleep(); + await waitFakeTimer(); expect(onFinish).toHaveBeenLastCalledWith({ list: ['input1', 'input2', 'input3'] }); await click(container, '.remove'); // will remove first input fireEvent.submit(container.querySelector('form')!); - await sleep(); + await waitFakeTimer(); expect(onFinish).toHaveBeenLastCalledWith({ list: ['input2', 'input3'] }); }); it('list errors', async () => { - jest.useFakeTimers(); - let operation: FormListOperation; const { container } = render(
@@ -177,15 +199,8 @@ describe('Form.List', () => { ); async function addItem() { - await act(async () => { - operation.add(); - await sleep(100); - jest.runAllTimers(); - }); - - act(() => { - jest.runAllTimers(); - }); + operation.add(); + await waitFakeTimer(); } await addItem(); @@ -193,8 +208,6 @@ describe('Form.List', () => { await addItem(); expect(container.getElementsByClassName('ant-form-item-explain div')).toHaveLength(0); - - jest.useRealTimers(); }); it('should render empty without errors', () => { @@ -243,7 +256,7 @@ describe('Form.List', () => { const { container } = render(); fireEvent.click(container.querySelector('button')!); - await sleep(); + await waitFakeTimer(); expect(errorSpy).not.toHaveBeenCalled(); From 30d2a248983b8c96d3e413c3c675ab2385806daa Mon Sep 17 00:00:00 2001 From: hms181231 Date: Fri, 21 Oct 2022 15:07:44 +0800 Subject: [PATCH 06/23] test: Update Dropdown test case (#38144) --- components/dropdown/__tests__/index.test.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/dropdown/__tests__/index.test.tsx b/components/dropdown/__tests__/index.test.tsx index 1bda134bc7..68dd830cfd 100644 --- a/components/dropdown/__tests__/index.test.tsx +++ b/components/dropdown/__tests__/index.test.tsx @@ -4,7 +4,7 @@ import Dropdown from '..'; import type { DropDownProps } from '..'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; -import { act, fireEvent, render, sleep } from '../../../tests/utils'; +import { act, fireEvent, render, waitFakeTimer } from '../../../tests/utils'; import Menu from '../../menu'; let triggerProps: TriggerProps; @@ -55,6 +55,7 @@ describe('Dropdown', () => { }); it('support Menu expandIcon', async () => { + jest.useFakeTimers(); const props: DropDownProps = { overlay: ( }> @@ -73,8 +74,9 @@ describe('Dropdown', () => { , ); - await sleep(500); + await waitFakeTimer(); expect(container.querySelectorAll('#customExpandIcon').length).toBe(1); + jest.useRealTimers(); }); it('should warn if use topCenter or bottomCenter', () => { From dae4b673206f1ca07dca72d55c5426aa91f48bf1 Mon Sep 17 00:00:00 2001 From: hms181231 Date: Fri, 21 Oct 2022 15:09:21 +0800 Subject: [PATCH 07/23] test: Update Collapse test case (#38145) --- components/collapse/__tests__/index.test.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/collapse/__tests__/index.test.tsx b/components/collapse/__tests__/index.test.tsx index a054eca1ba..46fb8a0979 100644 --- a/components/collapse/__tests__/index.test.tsx +++ b/components/collapse/__tests__/index.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { sleep, render, fireEvent } from '../../../tests/utils'; +import { waitFakeTimer, render, fireEvent } from '../../../tests/utils'; import { resetWarned } from '../../_util/warning'; describe('Collapse', () => { @@ -66,6 +66,7 @@ describe('Collapse', () => { }); it('could be expand and collapse', async () => { + jest.useFakeTimers(); const { container } = render( @@ -77,10 +78,11 @@ describe('Collapse', () => { container.querySelector('.ant-collapse-item')?.classList.contains('ant-collapse-item-active'), ).toBe(false); fireEvent.click(container.querySelector('.ant-collapse-header')!); - await sleep(400); + await waitFakeTimer(); expect( container.querySelector('.ant-collapse-item')?.classList.contains('ant-collapse-item-active'), ).toBe(true); + jest.useRealTimers(); }); it('could override default openMotion', () => { From 5159bb908401c41a06784537f4341d4ade4d4ee2 Mon Sep 17 00:00:00 2001 From: hms181231 Date: Fri, 21 Oct 2022 15:09:48 +0800 Subject: [PATCH 08/23] test: Update Carousel test case (#38146) --- components/carousel/__tests__/index.test.tsx | 22 +++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/components/carousel/__tests__/index.test.tsx b/components/carousel/__tests__/index.test.tsx index 85e85fc458..3865f8f94f 100644 --- a/components/carousel/__tests__/index.test.tsx +++ b/components/carousel/__tests__/index.test.tsx @@ -3,7 +3,7 @@ import type { CarouselRef } from '..'; import Carousel from '..'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; -import { sleep, render, act } from '../../../tests/utils'; +import { waitFakeTimer, render } from '../../../tests/utils'; describe('Carousel', () => { mountTest(Carousel); @@ -17,14 +17,6 @@ describe('Carousel', () => { jest.useRealTimers(); }); - function runAllTimersWithAct(times = 1) { - for (let i = 0; i < times; i++) { - act(() => { - jest.runAllTimers(); - }); - } - } - it('should has innerSlider', () => { const ref = React.createRef(); render( @@ -51,16 +43,16 @@ describe('Carousel', () => { expect(typeof goTo).toBe('function'); expect(ref.current?.innerSlider.state.currentSlide).toBe(0); ref.current?.goTo(2); - runAllTimersWithAct(1); + await waitFakeTimer(); expect(ref.current?.innerSlider.state.currentSlide).toBe(2); // wait for animation to be finished - runAllTimersWithAct(2); + await waitFakeTimer(); ref.current?.prev(); - runAllTimersWithAct(1); + await waitFakeTimer(); expect(ref.current?.innerSlider.state.currentSlide).toBe(1); - runAllTimersWithAct(2); + await waitFakeTimer(); ref.current?.next(); - runAllTimersWithAct(1); + await waitFakeTimer(); expect(ref.current?.innerSlider.state.currentSlide).toBe(2); }); @@ -77,7 +69,7 @@ describe('Carousel', () => { const spy = jest.spyOn(ref.current?.innerSlider, 'autoPlay'); window.resizeTo(1000, window.outerHeight); expect(spy).not.toHaveBeenCalled(); - await sleep(500); + await waitFakeTimer(); expect(spy).toHaveBeenCalled(); }); From 2e389d73ab82009cad92fd33598df7c4165ac61b Mon Sep 17 00:00:00 2001 From: hms181231 Date: Fri, 21 Oct 2022 15:10:20 +0800 Subject: [PATCH 09/23] test: Update back-top test case (#38147) --- components/back-top/__tests__/index.test.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/back-top/__tests__/index.test.tsx b/components/back-top/__tests__/index.test.tsx index 0ff9cea619..a4e625e4b5 100644 --- a/components/back-top/__tests__/index.test.tsx +++ b/components/back-top/__tests__/index.test.tsx @@ -2,13 +2,15 @@ import React from 'react'; import BackTop from '..'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; -import { fireEvent, render, sleep } from '../../../tests/utils'; +import { fireEvent, render, waitFakeTimer } from '../../../tests/utils'; describe('BackTop', () => { mountTest(BackTop); rtlTest(BackTop); it('should scroll to top after click it', async () => { + jest.useFakeTimers(); + const { container } = render(); const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((_, y) => { window.scrollY = y; @@ -18,9 +20,12 @@ describe('BackTop', () => { window.scrollTo(0, 400); expect(document.documentElement.scrollTop).toBe(400); fireEvent.click(container.querySelector('.ant-back-top')!); - await sleep(500); + await waitFakeTimer(); expect(document.documentElement.scrollTop).toBe(0); scrollToSpy.mockRestore(); + + jest.clearAllTimers(); + jest.useRealTimers(); }); it('support onClick', async () => { From 92acca41dec01b65c987bf13f3282cd265d27e14 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: Fri, 21 Oct 2022 16:25:42 +0800 Subject: [PATCH 10/23] docs: Add faq about breaking change (#38153) * docs: Add faq about breaking change * Update docs/react/faq.zh-CN.md Co-authored-by: afc163 * docs: update * docs: more desc Co-authored-by: afc163 --- docs/react/faq.en-US.md | 12 ++++++++++++ docs/react/faq.zh-CN.md | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/react/faq.en-US.md b/docs/react/faq.en-US.md index 6305fe6360..5cd52ba748 100644 --- a/docs/react/faq.en-US.md +++ b/docs/react/faq.en-US.md @@ -49,6 +49,18 @@ See: https://ant.design/docs/react/customize-theme . While you can override a component's style, we don't recommend doing so. antd is not only a set of React components, but also a design specification as well. +## How to avoid breaking change when update version? + +antd will avoid breaking change in minor & patch version. You can safe do follow things: + +- Official demo usage +- FAQ suggestion. Including codesandbox sample, marked as FAQ issue + +And which you should avoid to do: + +- Bug as feature. It will break in any other case (e.g. Use div as Tabs children) +- Use magic code to realize requirement but which can be realized with normal API + ## How do I replace Moment.js with Day.js to reduce bundle size? Please refer to [Replace Moment.js](/docs/react/replace-moment). diff --git a/docs/react/faq.zh-CN.md b/docs/react/faq.zh-CN.md index b328d25ec3..4e64a56f81 100644 --- a/docs/react/faq.zh-CN.md +++ b/docs/react/faq.zh-CN.md @@ -49,6 +49,18 @@ title: FAQ 你可以覆盖它们的样式,但是我们不推荐这么做。antd 是一系列 React 组件,但同样是一套设计规范。 +## 如何避免升级导致的破坏性变更? + +antd 在 minor 和 patch 版本迭代中会避免引入破坏性变更,遵从以下原则会确保不会破坏你的代码: + +- 使用出现在官方 Demo 中的写法 +- FAQ 中出现的解法,包含代码片段以及 codesandbox 示例、issue 中当前版本标记 FAQ label 的 + +而下述变更则需要开发者自行校验: + +- 特定场景的错误用法,BUG as Feature(例如 Tabs 下直接包 div 的用法) +- 可以通过正常用法实现功能需求却魔改的 + ## 如何使用 Day.js 替换 Moment.js 来减小打包大小? 可以参考[替换 Moment.js](/docs/react/replace-moment)。 From 8054769307de55194174d05ac50aac55bb1bb8eb Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 22 Oct 2022 15:00:26 +0800 Subject: [PATCH 11/23] refactor: delete defaultprops (#38154) * refactor: delete defaultprops * test: add test * fix: fix --- components/transfer/__tests__/list.test.tsx | 10 ++++++++++ components/transfer/list.tsx | 12 +++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/transfer/__tests__/list.test.tsx b/components/transfer/__tests__/list.test.tsx index 865ff42d37..1b8f65ec11 100644 --- a/components/transfer/__tests__/list.test.tsx +++ b/components/transfer/__tests__/list.test.tsx @@ -14,6 +14,11 @@ const listCommonProps: TransferListProps = { notFoundContent: 'Not Found', } as TransferListProps; +const listProps: TransferListProps = { + ...listCommonProps, + dataSource: undefined as unknown as any[], +}; + describe('Transfer.List', () => { it('should render correctly', () => { const { container } = render(); @@ -43,4 +48,9 @@ describe('Transfer.List', () => { expect(instance.current?.handleFilter({ target: 'test' })).toBe(undefined); expect(handleFilter).toHaveBeenCalled(); }); + it('should render correctly when dataSource is not exists', () => { + expect(() => { + render(); + }).not.toThrow(); + }); }); diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index a6e132b64d..725ef49dc4 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -81,12 +81,6 @@ interface TransferListState { export default class TransferList< RecordType extends KeyWiseTransferItem, > extends React.PureComponent, TransferListState> { - static defaultProps = { - dataSource: [], - titleText: '', - showSearch: false, - }; - timer: number; triggerScrollTimer: number; @@ -305,12 +299,12 @@ export default class TransferList< const { filterValue } = this.state; const { prefixCls, - dataSource, - titleText, + dataSource = [], + titleText = '', checkedKeys, disabled, footer, - showSearch, + showSearch = false, style, searchPlaceholder, notFoundContent, From a302d128e25927197a47d1bc35706e815d500c93 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 22 Oct 2022 18:43:36 +0800 Subject: [PATCH 12/23] refactor: delete defaultprops (#38164) * refactor: delete defaultprops * fix: fix eslint * fix: fix eslint * fix: fix eslint --- .../transfer/__tests__/customize.test.tsx | 3 ++- components/transfer/demo/table-transfer.md | 4 ++- components/transfer/index.tsx | 26 +++++++------------ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/components/transfer/__tests__/customize.test.tsx b/components/transfer/__tests__/customize.test.tsx index 6731a92b9d..aae9558413 100644 --- a/components/transfer/__tests__/customize.test.tsx +++ b/components/transfer/__tests__/customize.test.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { render } from '../../../tests/utils'; +import type { TransferProps } from '../index'; import Transfer from '../index'; describe('Transfer.Customize', () => { @@ -15,7 +16,7 @@ describe('Transfer.Customize', () => { it('props#body does not work anymore', () => { const body = jest.fn(); - const props = { body }; + const props = { body } as TransferProps; render(); expect(errorSpy).not.toHaveBeenCalled(); expect(body).not.toHaveBeenCalled(); diff --git a/components/transfer/demo/table-transfer.md b/components/transfer/demo/table-transfer.md index 3ba3ec8b2a..06ae3d7a3b 100644 --- a/components/transfer/demo/table-transfer.md +++ b/components/transfer/demo/table-transfer.md @@ -29,9 +29,11 @@ interface RecordType { } interface DataType { + key: string; title: string; - tag: string; description: string; + disabled: boolean; + tag: string; } interface TableTransferProps extends TransferProps { diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 05d85b5ee0..9c4eb45938 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -69,7 +69,7 @@ export interface TransferProps { prefixCls?: string; className?: string; disabled?: boolean; - dataSource: RecordType[]; + dataSource?: RecordType[]; targetKeys?: string[]; selectedKeys?: string[]; render?: TransferRender; @@ -116,13 +116,6 @@ class Transfer extends React.Com static Search = Search; - static defaultProps = { - dataSource: [], - locale: {}, - showSearch: false, - listStyle: () => {}, - }; - static getDerivedStateFromProps({ selectedKeys, targetKeys, @@ -180,11 +173,10 @@ class Transfer extends React.Com return this.props.titles ?? transferLocale.titles ?? []; } - getLocale = (transferLocale: TransferLocale, renderEmpty: RenderEmptyHandler) => ({ - ...transferLocale, - notFoundContent: renderEmpty('Transfer'), - ...this.props.locale, - }); + getLocale = (transferLocale: TransferLocale, renderEmpty: RenderEmptyHandler) => { + const { locale = {} } = this.props; + return { ...transferLocale, notFoundContent: renderEmpty('Transfer'), ...locale }; + }; moveTo = (direction: TransferDirection) => { const { targetKeys = [], dataSource = [], onChange } = this.props; @@ -192,7 +184,7 @@ class Transfer extends React.Com const moveKeys = direction === 'right' ? sourceSelectedKeys : targetSelectedKeys; // filter the disabled options const newMoveKeys = moveKeys.filter( - (key: string) => !dataSource.some(data => !!(key === data.key && data.disabled)), + key => !dataSource.some(data => !!(key === data.key && data.disabled)), ); // move items to target box const newTargetKeys = @@ -324,7 +316,7 @@ class Transfer extends React.Com }; separateDataSource() { - const { dataSource, rowKey, targetKeys = [] } = this.props; + const { dataSource = [], rowKey, targetKeys = [] } = this.props; const leftDataSource: KeyWise[] = []; const rightDataSource: KeyWise[] = new Array(targetKeys.length); @@ -365,10 +357,10 @@ class Transfer extends React.Com className, disabled, operations = [], - showSearch, + showSearch = false, footer, style, - listStyle, + listStyle = {}, operationStyle, filterOption, render, From ba3ab898d2251d582468231589b5933c64689a6f Mon Sep 17 00:00:00 2001 From: Marcia Sun Date: Sat, 22 Oct 2022 19:11:31 +0800 Subject: [PATCH 13/23] fix: incorrect transform-origin of tooltips (#38159) For tooltips with a placement value like 'topRight' or 'bottomLeft', the previous code would calculate an incorrect transform-origin, which is fixed here. --- components/tooltip/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 8dcc973b15..5f2a72d1b3 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -237,14 +237,14 @@ const Tooltip = React.forwardRef((props, ref) => { const transformOrigin = { top: '50%', left: '50%' }; - if (['top', 'Bottom'].includes(placement)) { + if (/top|Bottom/.test(placement)) { transformOrigin.top = `${rect.height - align.offset![1]}px`; - } else if (['Top', 'bottom'].includes(placement)) { + } else if (/Top|bottom/.test(placement)) { transformOrigin.top = `${-align.offset![1]}px`; } - if (['left', 'Right'].includes(placement)) { + if (/left|Right/.test(placement)) { transformOrigin.left = `${rect.width - align.offset![0]}px`; - } else if (['right', 'Left'].includes(placement)) { + } else if (/right|Left/.test(placement)) { transformOrigin.left = `${-align.offset![0]}px`; } domNode.style.transformOrigin = `${transformOrigin.left} ${transformOrigin.top}`; From 80ad128aeb92ad5b8b36a9e947745dd7c86ba1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 23 Oct 2022 15:23:16 +0800 Subject: [PATCH 14/23] fix: add titles for transer in locale (#38168) Co-authored-by: tangwenhui --- components/locale/ar_EG.tsx | 1 + components/locale/bg_BG.tsx | 1 + components/locale/da_DK.tsx | 1 + components/locale/el_GR.tsx | 1 + components/locale/fi_FI.tsx | 1 + components/locale/fr_BE.tsx | 1 + components/locale/fr_CA.tsx | 1 + components/locale/gl_ES.tsx | 1 + components/locale/he_IL.tsx | 1 + components/locale/hu_HU.tsx | 1 + components/locale/is_IS.tsx | 1 + components/locale/it_IT.tsx | 4 ++-- components/locale/ja_JP.tsx | 1 + components/locale/km_KH.tsx | 1 + components/locale/kmr_IQ.tsx | 1 + components/locale/ko_KR.tsx | 1 + components/locale/ku_IQ.tsx | 1 + components/locale/lv_LV.tsx | 1 + components/locale/mk_MK.tsx | 1 + components/locale/mn_MN.tsx | 1 + components/locale/ms_MY.tsx | 1 + components/locale/sl_SI.tsx | 1 + components/locale/vi_VN.tsx | 1 + components/locale/zh_CN.tsx | 1 + components/locale/zh_HK.tsx | 1 + components/locale/zh_TW.tsx | 1 + 26 files changed, 27 insertions(+), 2 deletions(-) diff --git a/components/locale/ar_EG.tsx b/components/locale/ar_EG.tsx index 60e26b4944..9be2083032 100644 --- a/components/locale/ar_EG.tsx +++ b/components/locale/ar_EG.tsx @@ -40,6 +40,7 @@ const localeValues: Locale = { cancelText: 'إلغاء', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'ابحث هنا', itemUnit: 'عنصر', itemsUnit: 'عناصر', diff --git a/components/locale/bg_BG.tsx b/components/locale/bg_BG.tsx index f466fc1e79..a745b202f3 100644 --- a/components/locale/bg_BG.tsx +++ b/components/locale/bg_BG.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Отказ', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Търсене', itemUnit: 'избор', itemsUnit: 'избори', diff --git a/components/locale/da_DK.tsx b/components/locale/da_DK.tsx index 03414142c4..56f03be6f0 100644 --- a/components/locale/da_DK.tsx +++ b/components/locale/da_DK.tsx @@ -37,6 +37,7 @@ const localeValues: Locale = { cancelText: 'Afbryd', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Søg her', itemUnit: 'element', itemsUnit: 'elementer', diff --git a/components/locale/el_GR.tsx b/components/locale/el_GR.tsx index 644f7c6491..ba5e26b3da 100644 --- a/components/locale/el_GR.tsx +++ b/components/locale/el_GR.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Άκυρο', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Αναζήτηση', itemUnit: 'αντικείμενο', itemsUnit: 'αντικείμενα', diff --git a/components/locale/fi_FI.tsx b/components/locale/fi_FI.tsx index df9207831d..6b0cb7cbec 100644 --- a/components/locale/fi_FI.tsx +++ b/components/locale/fi_FI.tsx @@ -31,6 +31,7 @@ const localeValues: Locale = { cancelText: 'Peruuta', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Etsi täältä', itemUnit: 'kohde', itemsUnit: 'kohdetta', diff --git a/components/locale/fr_BE.tsx b/components/locale/fr_BE.tsx index d234603cf1..dd520c9f1b 100644 --- a/components/locale/fr_BE.tsx +++ b/components/locale/fr_BE.tsx @@ -26,6 +26,7 @@ const localeValues: Locale = { cancelText: 'Annuler', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Recherche', itemUnit: 'élément', itemsUnit: 'éléments', diff --git a/components/locale/fr_CA.tsx b/components/locale/fr_CA.tsx index 21eafa6624..bee3c7a04e 100644 --- a/components/locale/fr_CA.tsx +++ b/components/locale/fr_CA.tsx @@ -35,6 +35,7 @@ const localeValues: Locale = { cancelText: 'Annuler', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Rechercher', itemUnit: 'élément', itemsUnit: 'éléments', diff --git a/components/locale/gl_ES.tsx b/components/locale/gl_ES.tsx index b6b59a0899..8e1d135901 100644 --- a/components/locale/gl_ES.tsx +++ b/components/locale/gl_ES.tsx @@ -34,6 +34,7 @@ const localeValues: Locale = { cancelText: 'Cancelar', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Buscar aquí', itemUnit: 'elemento', itemsUnit: 'elementos', diff --git a/components/locale/he_IL.tsx b/components/locale/he_IL.tsx index b9c809f627..c0fc9a6f87 100644 --- a/components/locale/he_IL.tsx +++ b/components/locale/he_IL.tsx @@ -40,6 +40,7 @@ const localeValues: Locale = { cancelText: 'ביטול', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'חפש כאן', itemUnit: 'פריט', itemsUnit: 'פריטים', diff --git a/components/locale/hu_HU.tsx b/components/locale/hu_HU.tsx index cbdc228b10..d3385bf094 100644 --- a/components/locale/hu_HU.tsx +++ b/components/locale/hu_HU.tsx @@ -28,6 +28,7 @@ const localeValues: Locale = { cancelText: 'Visszavonás', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Keresés', itemUnit: 'elem', itemsUnit: 'elemek', diff --git a/components/locale/is_IS.tsx b/components/locale/is_IS.tsx index ce2905fc95..0ecec8f953 100644 --- a/components/locale/is_IS.tsx +++ b/components/locale/is_IS.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Hætta við', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Leita hér', itemUnit: 'færsla', itemsUnit: 'færslur', diff --git a/components/locale/it_IT.tsx b/components/locale/it_IT.tsx index e3b968839a..f5ccc038af 100644 --- a/components/locale/it_IT.tsx +++ b/components/locale/it_IT.tsx @@ -45,7 +45,7 @@ const localeValues: Locale = { cancelText: 'Annulla', }, Transfer: { - titles: ['', ''], + titles: ['', ''], searchPlaceholder: 'Cerca qui', itemUnit: 'elemento', itemsUnit: 'elementi', @@ -75,7 +75,7 @@ const localeValues: Locale = { copied: 'copia effettuata', expand: 'espandi', }, - PageHeader: { + PageHeader: { back: 'Torna', }, Form: { diff --git a/components/locale/ja_JP.tsx b/components/locale/ja_JP.tsx index 5e41daac51..2ee099d323 100644 --- a/components/locale/ja_JP.tsx +++ b/components/locale/ja_JP.tsx @@ -38,6 +38,7 @@ const localeValues: Locale = { cancelText: 'キャンセル', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'ここを検索', itemUnit: 'アイテム', itemsUnit: 'アイテム', diff --git a/components/locale/km_KH.tsx b/components/locale/km_KH.tsx index 33b04c8e84..79663471a7 100644 --- a/components/locale/km_KH.tsx +++ b/components/locale/km_KH.tsx @@ -40,6 +40,7 @@ const localeValues: Locale = { cancelText: 'បោះបង់', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'ស្វែងរកនៅទីនេះ', itemUnit: '', itemsUnit: 'items', diff --git a/components/locale/kmr_IQ.tsx b/components/locale/kmr_IQ.tsx index 8cd6d54bd3..147b15fbe6 100644 --- a/components/locale/kmr_IQ.tsx +++ b/components/locale/kmr_IQ.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Betal ke', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Lêgerîn', itemUnit: 'tişt', itemsUnit: 'tişt', diff --git a/components/locale/ko_KR.tsx b/components/locale/ko_KR.tsx index 647b432074..f02da311ef 100644 --- a/components/locale/ko_KR.tsx +++ b/components/locale/ko_KR.tsx @@ -32,6 +32,7 @@ const localeValues: Locale = { cancelText: '취소', }, Transfer: { + titles: ['', ''], searchPlaceholder: '여기에 검색하세요', itemUnit: '개', itemsUnit: '개', diff --git a/components/locale/ku_IQ.tsx b/components/locale/ku_IQ.tsx index d2384601f5..ca5839e3aa 100755 --- a/components/locale/ku_IQ.tsx +++ b/components/locale/ku_IQ.tsx @@ -31,6 +31,7 @@ const localeValues: Locale = { cancelText: 'Betal ke', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Lêgerîn', itemUnit: 'tişt', itemsUnit: 'tişt', diff --git a/components/locale/lv_LV.tsx b/components/locale/lv_LV.tsx index a7e711638f..26ad88713a 100644 --- a/components/locale/lv_LV.tsx +++ b/components/locale/lv_LV.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Atcelt', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Meklēt šeit', itemUnit: 'vienumu', itemsUnit: 'vienumus', diff --git a/components/locale/mk_MK.tsx b/components/locale/mk_MK.tsx index d0a387cdc9..c523b35c27 100644 --- a/components/locale/mk_MK.tsx +++ b/components/locale/mk_MK.tsx @@ -30,6 +30,7 @@ const localeValues: Locale = { cancelText: 'Откажи', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Пребарај тука', itemUnit: 'предмет', itemsUnit: 'предмети', diff --git a/components/locale/mn_MN.tsx b/components/locale/mn_MN.tsx index d3d6b7f58b..94c5fe4d2d 100644 --- a/components/locale/mn_MN.tsx +++ b/components/locale/mn_MN.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Цуцлах', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Хайх', itemUnit: 'Зүйл', itemsUnit: 'Зүйлүүд', diff --git a/components/locale/ms_MY.tsx b/components/locale/ms_MY.tsx index 736083e283..993c4b9fc2 100644 --- a/components/locale/ms_MY.tsx +++ b/components/locale/ms_MY.tsx @@ -43,6 +43,7 @@ const localeValues: Locale = { cancelText: 'Batal', }, Transfer: { + titles: ['', ''], notFoundContent: 'Tidak dijumpai', searchPlaceholder: 'Carian di sini', itemUnit: 'item', diff --git a/components/locale/sl_SI.tsx b/components/locale/sl_SI.tsx index 74ca51971a..ea02ff43c4 100644 --- a/components/locale/sl_SI.tsx +++ b/components/locale/sl_SI.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Prekliči', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Išči tukaj', itemUnit: 'Objekt', itemsUnit: 'Objektov', diff --git a/components/locale/vi_VN.tsx b/components/locale/vi_VN.tsx index 0af968dd01..369686728a 100644 --- a/components/locale/vi_VN.tsx +++ b/components/locale/vi_VN.tsx @@ -27,6 +27,7 @@ const localeValues: Locale = { cancelText: 'Huỷ', }, Transfer: { + titles: ['', ''], searchPlaceholder: 'Tìm ở đây', itemUnit: 'mục', itemsUnit: 'mục', diff --git a/components/locale/zh_CN.tsx b/components/locale/zh_CN.tsx index 66d38cecad..4750fb6c16 100644 --- a/components/locale/zh_CN.tsx +++ b/components/locale/zh_CN.tsx @@ -45,6 +45,7 @@ const localeValues: Locale = { okText: '确定', }, Transfer: { + titles: ['', ''], searchPlaceholder: '请输入搜索内容', itemUnit: '项', itemsUnit: '项', diff --git a/components/locale/zh_HK.tsx b/components/locale/zh_HK.tsx index f8dce3dbd2..d8eb4800e3 100644 --- a/components/locale/zh_HK.tsx +++ b/components/locale/zh_HK.tsx @@ -42,6 +42,7 @@ const localeValues: Locale = { cancelText: '取消', }, Transfer: { + titles: ['', ''], searchPlaceholder: '搜尋資料', itemUnit: '項目', itemsUnit: '項目', diff --git a/components/locale/zh_TW.tsx b/components/locale/zh_TW.tsx index 6b3445d8e3..07ca16f0e5 100644 --- a/components/locale/zh_TW.tsx +++ b/components/locale/zh_TW.tsx @@ -42,6 +42,7 @@ const localeValues: Locale = { cancelText: '取消', }, Transfer: { + titles: ['', ''], searchPlaceholder: '搜尋資料', itemUnit: '項目', itemsUnit: '項目', From 70232ab10b55426b73dd6bfc0f2a786172e2ed5e Mon Sep 17 00:00:00 2001 From: Chang Wei Date: Sun, 23 Oct 2022 15:26:51 +0800 Subject: [PATCH 15/23] chore: update icon category (#38177) * chore: add icon 'WhatsApp' to category 'logo' * chore: add icon 'Dingtalk' to category 'logo' --- site/theme/template/IconDisplay/fields.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/theme/template/IconDisplay/fields.ts b/site/theme/template/IconDisplay/fields.ts index 2e0f954bfe..de37e675cf 100644 --- a/site/theme/template/IconDisplay/fields.ts +++ b/site/theme/template/IconDisplay/fields.ts @@ -200,6 +200,8 @@ const logo = [ 'Yahoo', 'Reddit', 'Sketch', + 'WhatsApp', + 'Dingtalk', ]; const datum = [...direction, ...suggestion, ...editor, ...data, ...logo]; From 21c4bcf40ab3aea8b2681f70c45b23a4d37de43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 23 Oct 2022 15:28:26 +0800 Subject: [PATCH 16/23] fix(table): aria-label should be use the first text content in element when column title is ReactElement in table (#38160) * fix: aria-lable should be use the first text content in element when title is ReactElement * fix: aria-label should be use the first text content in element when title is ReactElement * feat: optimize code * feat: optimize code * feat: optimize code * feat: optimize code * feat: update snapshots * feat: update snapshots Co-authored-by: tangwenhui --- .../table/__tests__/Table.sorter.test.tsx | 26 +++++++++++++++++++ components/table/util.ts | 23 ++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/components/table/__tests__/Table.sorter.test.tsx b/components/table/__tests__/Table.sorter.test.tsx index 2509419833..8b0d93c5c5 100644 --- a/components/table/__tests__/Table.sorter.test.tsx +++ b/components/table/__tests__/Table.sorter.test.tsx @@ -108,6 +108,32 @@ describe('Table.sorter', () => { expect(getNameColumn()?.getAttribute('aria-label')).toEqual('Name sortable'); }); + it('aria-label should be use the first text content in element when title is ReactElement', () => { + const { container } = render( + createTable( + { + sortDirections: ['descend', 'ascend'], + }, + { + title: ( + + Name + kiner + + ), + defaultSortOrder: 'descend', + }, + ), + ); + + const getNameColumn = () => container.querySelector('th'); + fireEvent.click(container.querySelector('.ant-table-column-sorters')!); + expect(getNameColumn()?.getAttribute('aria-sort')).toEqual('ascending'); + expect(getNameColumn()?.getAttribute('aria-label')).toEqual(null); + fireEvent.click(container.querySelector('.ant-table-column-sorters')!); + expect(getNameColumn()?.getAttribute('aria-label')).toEqual('Name sortable'); + }); + it('sort records', () => { const { container } = render(createTable()); const getNameColumn = () => container.querySelector('th'); diff --git a/components/table/util.ts b/components/table/util.ts index 4a355c1ef7..e6394f186e 100644 --- a/components/table/util.ts +++ b/components/table/util.ts @@ -1,4 +1,5 @@ /* eslint-disable import/prefer-default-export */ +import React from 'react'; import type { ColumnTitle, ColumnTitleProps, ColumnType, Key } from './interface'; export function getColumnKey(column: ColumnType, defaultKey: string): Key { @@ -16,6 +17,22 @@ export function getColumnPos(index: number, pos?: string) { return pos ? `${pos}-${index}` : `${index}`; } +/** + * Get first text content in Element + * + * @param node + * @returns + */ +function getElementFirstTextContent(node: React.ReactElement): string { + if (!node || !node.props || !node.props.children) return ''; + if (typeof node.props.children === 'string') return node.props.children; + return ( + node.props.children?.map?.((item: React.ReactElement) => + getElementFirstTextContent(item), + )?.[0] || '' + ); +} + export function renderColumnTitle( title: ColumnTitle, props: ColumnTitleProps, @@ -23,6 +40,12 @@ export function renderColumnTitle( if (typeof title === 'function') { return title(props); } + // fix: #38155 + if (React.isValidElement(title)) { + // if title is a React Element, we should get first text content as result, + // if there has not text content in React Element, return origin title + return getElementFirstTextContent(title) || title; + } return title; } From 072fda0f1574057863e6ea1cb139a595f7ebcf8e Mon Sep 17 00:00:00 2001 From: zz <2418184580@qq.com> Date: Sun, 23 Oct 2022 16:05:31 +0800 Subject: [PATCH 17/23] refactor(Typography.Link): simplify code (#38181) --- components/typography/Link.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/typography/Link.tsx b/components/typography/Link.tsx index a576beaad9..36745f0f31 100644 --- a/components/typography/Link.tsx +++ b/components/typography/Link.tsx @@ -16,10 +16,6 @@ const Link = React.forwardRef(({ ellipsis, rel, ...restP '`ellipsis` only supports boolean value.', ); - const baseRef = React.useRef(null); - - React.useImperativeHandle(ref, () => baseRef.current); - const mergedProps = { ...restProps, rel: rel === undefined && restProps.target === '_blank' ? 'noopener noreferrer' : rel, @@ -28,7 +24,7 @@ const Link = React.forwardRef(({ ellipsis, rel, ...restP // @ts-expect-error: https://github.com/ant-design/ant-design/issues/26622 delete mergedProps.navigate; - return ; + return ; }); export default Link; From 2a1f2836f48adbb6ef862a07cc815ae73fd2a4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 23 Oct 2022 16:06:50 +0800 Subject: [PATCH 18/23] fix: Transfer throw error when`titles` is undefined (#38182) Co-authored-by: tangwenhui --- components/transfer/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 9c4eb45938..771c870403 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -398,7 +398,7 @@ class Transfer extends React.Com
> prefixCls={`${prefixCls}-list`} - titleText={titles[0]} + titleText={titles?.[0]} dataSource={leftDataSource} filterOption={filterOption} style={this.handleListStyle(listStyle, 'left')} @@ -434,7 +434,7 @@ class Transfer extends React.Com /> > prefixCls={`${prefixCls}-list`} - titleText={titles[1]} + titleText={titles?.[1]} dataSource={rightDataSource} filterOption={filterOption} style={this.handleListStyle(listStyle, 'right')} From 9d9447e54f45b9673cc18856897bd1e55503184a Mon Sep 17 00:00:00 2001 From: zz <2418184580@qq.com> Date: Sun, 23 Oct 2022 18:33:47 +0800 Subject: [PATCH 19/23] refactor(DirectoryTree): simplify code (#38184) --- components/tree/DirectoryTree.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/tree/DirectoryTree.tsx b/components/tree/DirectoryTree.tsx index 96dfc84578..914973981a 100644 --- a/components/tree/DirectoryTree.tsx +++ b/components/tree/DirectoryTree.tsx @@ -52,10 +52,6 @@ const DirectoryTree: React.ForwardRefRenderFunction const cachedSelectedKeys = React.useRef(); - const treeRef = React.createRef(); - - React.useImperativeHandle(ref, () => treeRef.current!); - const getInitExpandedKeys = () => { const { keyEntities } = convertDataToEntities(getTreeData(props)); @@ -191,7 +187,7 @@ const DirectoryTree: React.ForwardRefRenderFunction return ( Date: Tue, 25 Oct 2022 00:07:18 +0800 Subject: [PATCH 20/23] fix: Remove redundant warnings (#38190) Co-authored-by: tangwenhui --- components/time-picker/index.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/time-picker/index.tsx b/components/time-picker/index.tsx index 22e3c34787..354c2c1b9b 100644 --- a/components/time-picker/index.tsx +++ b/components/time-picker/index.tsx @@ -23,11 +23,6 @@ export interface TimeRangePickerProps extends Omit, const RangePicker = React.forwardRef((props, ref) => { const { dropdownClassName, popupClassName } = props; - warning( - !dropdownClassName, - 'RangePicker', - '`dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', - ); return ( Date: Tue, 25 Oct 2022 23:24:18 +0800 Subject: [PATCH 21/23] chore: remove redundant state (#38208) Co-authored-by: xingming --- components/date-picker/demo/select-in-range.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/date-picker/demo/select-in-range.md b/components/date-picker/demo/select-in-range.md index bda207bf54..25a6e5de60 100644 --- a/components/date-picker/demo/select-in-range.md +++ b/components/date-picker/demo/select-in-range.md @@ -24,7 +24,6 @@ type RangeValue = [Moment | null, Moment | null] | null; const App: React.FC = () => { const [dates, setDates] = useState(null); - const [hackValue, setHackValue] = useState(null); const [value, setValue] = useState(null); const disabledDate = (current: Moment) => { @@ -38,16 +37,15 @@ const App: React.FC = () => { const onOpenChange = (open: boolean) => { if (open) { - setHackValue([null, null]); setDates([null, null]); } else { - setHackValue(null); + setDates(null); } }; return ( setDates(val)} onChange={val => setValue(val)} From 2c8990773b071fdf18869d46abf8251b6a16a691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Wed, 26 Oct 2022 10:35:26 +0800 Subject: [PATCH 22/23] chore: update authors (#38214) Co-authored-by: tangwenhui --- AUTHORS.txt | 106 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 69a745a89e..c2070fc45a 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -6,6 +6,7 @@ 778758944 <778758944@qq.com> Aaron Cawte Aaron Planell López +Aaron674092290 Adam Stankiewicz Aditya Padhi Adrian Dimitrov @@ -19,6 +20,7 @@ Aiello <770540123@qq.com> AkiJoey Akshat Mittal Alan Braithwaite +Alan Deng Albert Mañosa Albert Zhang Albert Zheng @@ -40,6 +42,7 @@ Alexey Vinogradov Alexey Yakovlev Alfred Qiu Ali Zhdanov +AliRezaBeigy Aliaksandr Alireza Alvin Abia @@ -52,6 +55,7 @@ Anas Tawfeek Andre Perunicic Andre Zyczkowski Andrea Blanco +Andrew Horn Andrew Murray Andrew Shearer Andrey G @@ -107,6 +111,7 @@ Bruno Maia Bryan Berger BugHiding <609228186@qq.com> C <4019980@qq.com> +C. T. Lin C.J. Winslow CORP\lianyufeng <15275222711@163.com> Calin Vlad @@ -124,6 +129,7 @@ Cemre Mengu Chalk Chandler Moisen Chang Wang +Chang Wei Chang Wei <867597730@qq.com> Charles Covey-Brandt Charlie Jonas @@ -151,11 +157,13 @@ Cong Yoo Cong Zhang Connor White Conway Anderson +Cooper Veysey Cordaro CornerSkyless <573196853@qq.com> Curly.Water D & R Daewoong Moon +Dalton Craven Damian Green Damian Green Dan Minshew @@ -183,7 +191,7 @@ Dean van Niekerk Debiancc DengYun Denis -Dennis273 +Dennis Chen Derrick Di Wu DiamondYuan @@ -205,6 +213,8 @@ Dorian DosLin Douglas Mason Dreamcreative +Dunqing +Dunqing <1247748612@qq.com> Dzmitry Yarmoshkin Eager <1226393396@qq.com> Eber Rodrigues @@ -233,6 +243,7 @@ Eric Lee Eric Turriff Eric Wang Eric Wang +Ernest Folch Erwann Mest Eslam Yahya Eugene Matvejev @@ -261,6 +272,7 @@ Fullstop000 GJ Wang GSBL <2602140596@qq.com> Gabe Medrash +Gabriel Haruki Gabriel Henrique Gabriel Le Breton Gabriel Mendez Reyes @@ -295,10 +307,10 @@ Guru Mahendran HJin.me Hai Phan Nguyen Haibin Yu -Hal-pan Hale Deng Han Han Hanai +Haniel Cui Hanjun Kim Hanz Luo HarlanLuo @@ -326,6 +338,8 @@ Hsuan Lee Hubert Argasinski Hughen <446370503@163.com> Hugo LEHMANN +Humble <745653239@qq.com> +Hyunseok.Kim ILdar Nogmanov Igor Igor Andriushchenko @@ -363,6 +377,7 @@ James James Tsang James Yeung JamesYin +Jamki <13414367591@163.com> Jan Václavík Janry Jaroslav Bereza @@ -377,6 +392,7 @@ Jay Fong Jean-Luc Sorak Jean-Philippe Roy Jeff Wen +Jefferson Rafael Kozerski Jeffrey Carl Faden Jehu Jelle de Jong @@ -413,6 +429,7 @@ John Carlo John Johnson III John Nguyen Johnny Lim +Johnny-young <1571779481@qq.com> Johnsen Jonatas Walker Jonathan Gabaut @@ -426,6 +443,7 @@ Josué JounQin JribiBelhassen Jtree03 +Ju/Smwhr JuFeng Zhang Juan Carlos Lloret H Juan Rodrigo Venegas Boesch @@ -442,7 +460,7 @@ Jógvan Olsen Kaan KÜÇÜK Kaien Liao Kamal Mahmudi -Karott Schu +Karott Kasra Bigdeli Kayson Wu <772663139@qq.com> Kelvin Chu @@ -478,6 +496,7 @@ Kuitos Kurt Furbush Kyle Kelley Kyle Rosenberg +Kyrielin LLinFan- LT246-VINHNPH\vinhnph Laith @@ -485,6 +504,7 @@ Larry Laski LaySent LeeHarlan <709886167@qq.com> LeezQ +Len LeoYang Leon Koole Leon Shi @@ -508,6 +528,7 @@ Lu Yu Lucien Lee Ludwig Bäcklund Luke Vella +Luobo Zhang Lyndon001 M Mitchell M. Burak Kalkan @@ -528,8 +549,10 @@ MaoYiWei <137308365@qq.com> Map1en_ Marcel Jackwerth Marcela Bomfim +Marcia Sun Marcio Pamplona Marco Afonso +Marco Heinrich Marcus Bransbury Marcus Stenbeck Marius Ileana @@ -547,6 +570,7 @@ Matt Wilkinson Max Maximilian Meyer Md_ZubairAhmed +Mehdi Salem Naraghi MeiLin MengZhaoFly <1424254461@qq.com> Meow-z <372086270@qq.com> @@ -596,6 +620,7 @@ Mr.jiangzhiguo Ms. Wang <767074895@qq.com> MuYu Muhammad Sameer +Mykyta Velykanov Mário Gonçalves Nariman Movaffaghi Nathan Broadbent @@ -605,6 +630,7 @@ Nathan Tavares Nascimento Nathan Wells Naveen Neekey +Neil <100huming@gmail.com> Nekron Neo Tan Neto Braghetto @@ -621,6 +647,7 @@ Nikolay Nikolay Solovyov Nima Dehnashi Nimo +NinJa <386805508@qq.com> Nishant Arora Niyaz Akhmetov Nokecy @@ -637,7 +664,6 @@ Oren Kosto Oren Kosto Orkhan Huseynli OuYancey -PCCCCCCC Pablo Recalde Panjie Setiawan Wicaksono Patrick Gidich @@ -647,6 +673,7 @@ Paul Julien Paul Julien Peach Pengsha Ying <810998652@qq.com> +Peritot Chan Peter Peter Berg Phanupong Janthapoon @@ -689,6 +716,7 @@ Regan Langford Renny Ren Renovate Bot Rex +Rex Zeng Ricardo Morais Ricardo Raphael Joson Richard D. Worth @@ -698,6 +726,7 @@ Robin Pokorny Rodrigo Ehlers Rohan Bagchi Rohan Malhotra +Ron Šmeral Rongjian Zhang Rrrandom RunningCoderLee @@ -748,6 +777,7 @@ Shun Shuvalov Anton SimaQ Simo Aleksandrov +Simon Simon Altschuler Simon Knott Siou @@ -767,12 +797,15 @@ Stevche Radevski Steven.zhong <953665604@qq.com> Subroto Suki小火车 <463355954@qq.com> +Sukka Sumit Vekariya Sunny Luo Sven Efftinge +Svyatoslav SyMind SylvanasGone <397009765@qq.com> TTC <345866517@qq.com> +TangLL Tanmoy Bhowmik Tannmay S Gupta Tao @@ -792,7 +825,6 @@ Thiebaud Thomas Thomas Thomas Ladd Thomas Zipner -Tianyuan Zhang Tino D Tmk Tom Gao @@ -809,7 +841,9 @@ TsesamLi Ty Mick Tyler Ubaldo Quintana +Uladzimir Atroshchanka Uladzimir Atroshchanka +Umberto Gariggio Vadim Macagon Valentin Vichnal Van Nguyen @@ -823,6 +857,7 @@ Vijay Thirugnanam Vincent Zhang Vineet Srivastav Viorel Cojocaru +Vishal Jagtap Vitaliy Mazurenko Vitaly Budovski ViviaRui @@ -838,22 +873,26 @@ Wang yb Warren Seymour Webber Takken Wei Zhu -WeijieChen Wenchao Hu Wendell Wendell Wenqi Chen <1264578441@qq.com> Wensheng Xu +Wesley Will Will Chen Will Soares +William Bergeron-Drouin William Cai William Stein WingGao Wu Haotian WuJiali <18767152447@163.com> +Wuxh +Wuxh X-Jagger XBTop1! +XIN HU XTY <^@xty.dev> Xiaoming Xie Guanglei @@ -869,6 +908,8 @@ Yaindrop YanYuan <1025138284@qq.com> Yang Bin Yangzhedi +Yanlin Jiang +Yanming Deng Yann Normand Yann Pringault Yash Joshi @@ -883,6 +924,7 @@ YuChao Liang YuTao Yuan <1076849402@qq.com> Yuhang Liu <644186735@qq.com> +Yuki Zhang Yulia Maximova Yunfly <120562638@qq.com> Yunus EŞ @@ -892,6 +934,7 @@ Yury Kozyrev Yusuke Ito Yuwei Ba Yuxuan Huo +Yuyao Nie YuyingWu ZHANGYU <723156735@qq.com> ZYSzys @@ -902,7 +945,9 @@ Zap ZeroToOne Zester Quinn Albano Zhang Zhi +Zheeeng Zheeeng +ZhiHao Li <940166841@qq.com> Zhiqiang Gong ZhouZhen <503633021@qq.com> Zhuo Chen @@ -915,6 +960,7 @@ aashutoshrathi acfasj adam afc163 +agarciaguillo agent-z <1607291079@qq.com> aghArdeshir ahalimkara @@ -943,6 +989,7 @@ benben bigbigbo binyellow <571704908@qq.com> blankzust <450811238@qq.com> +bobo <625391250@qq.com> btea <2356281422@qq.com> bukas byuanama @@ -960,6 +1007,8 @@ chen-jingjie <2383844893@qq.com> chencheng (云谦) chenlei <745512023@qq.com> chenlong +chensw +chenxiang <597219320@qq.com> chenxiaochun chequerNoel chisus @@ -968,10 +1017,12 @@ cieldon32 cjahv cjmafei <1135328499@qq.com> cjmafei +clean99 clinyong cnjs <1269075501@qq.com> codesign corneyl +csr632 <632882184@qq.com> daczczcz1 damon.chen david.lv @@ -980,7 +1031,6 @@ davidhatten ddcat1115 decade delesseps -dengqing <1247748612@qq.com> denzw dependabot[bot] desperado @@ -988,18 +1038,21 @@ detailyang devqin dian.li digz6666 +dingkang djorkaeff dolfje douxc dpyzo0o dujun duzliang +edc-hui edgji eidonjoe <806488716@qq.com> elios elrrrrrrr eruca ezpub +fairyland feeng feng zhi hao fengmk2 @@ -1008,6 +1061,7 @@ fkysly flashback313 flyerH frezc <504021398@qq.com> +gaokaifeis gaoryrt gaozhenqian <837856276@qq.com> genie @@ -1019,6 +1073,7 @@ gyh9457 gzq haianweifeng <1531297152@qq.com> haimrait +haipeng handy hank hanpei <75189218@qq.com> @@ -1034,6 +1089,7 @@ hello-chinese <841030329@qq.com> henryv0 hi-caicai hicrystal <295247343@qq.com> +hms181231 hongxuWei howard huangyan.py @@ -1063,13 +1119,16 @@ jiang.an jiang.he <573748150jh@163.com> jieniu$ jinouwuque +jinrui jinyaqiao1102 <405782493@QQ.com> jojoLockLock +joson <373693643@qq.com> jueinin <1014397160@qq.com> junjing.zhang kacjay <45483388@qq.com> kaifei <150641329@qq.com> kailunyao +kalykun <984757534@qq.com> kanweiwei <475801900@qq.com> kaoding <41830859@qq.com> kasinooya @@ -1081,6 +1140,7 @@ keng kenve kermolaev kily zhou +kiner-tang(文辉) <1127031143@qq.com> klouskingsley ko konakona @@ -1088,6 +1148,7 @@ kossel kristof0425 kuang kun sam +lalalazero leadream <857098475@qq.com> lehug leijingdao @@ -1100,19 +1161,25 @@ lhyt <515593899@qq.com> liangfei lich-yoo liekkas +lihao lihqi <455711093@qq.com> +lijianan <574980606@qq.com> lilun limingxin <906529775@qq.com> +linqiqi077 <865530219@qq.com> lisenenkov littleLane <857183384@qq.com> +littledian <1197434548@qq.com> liuchuzhang liuchuzhang +liuycy lixiaochou077 lixiaoyang1992 liyuanqiu lizhen llwslc loganpowell +losgif luyiming lvren lxnxbnq @@ -1135,6 +1202,7 @@ mraiguo <810158465@qq.com> mraiguo mumiao mushan0x0 +muxin muzuiget natergj netcon @@ -1143,15 +1211,18 @@ nick-ChenZe niko <644506165@qq.com> nitinknolder nnecec +nuintun nuintun oldchicken paleface001 +parabolazz paranoidjk parlop paul <34345790@qq.com> pbrink231 peiming pengtikui <949828390@qq.com> +pfsu picodoth picodoth pinggod @@ -1168,6 +1239,7 @@ qramilq qubaoming ravirambles realEago <774855001@qq.com> +rendaoer renzhao1113 <547249523@qq.com> richardison ryangun @@ -1186,6 +1258,7 @@ shelwin shlice shmilyKang <953333436@qq.com> shouyong +simplejason siyu77 slientcloud sliwey @@ -1215,6 +1288,7 @@ tom tom toshi1127 twobin +ty888 <1506125048@qq.com> u3u ubuntugod uchanlee @@ -1268,7 +1342,6 @@ xiejiahe xilihuasi <2857818553@qq.com> xinhui.zxh xrkffgg -xrkffgg xuqiang xyb <576420147@qq.com> xz @@ -1284,6 +1357,7 @@ yehq yeliex yeshan333 <1329441308@qq.com> yibu.wang +yifanwww yiminanci yiminghe yingxirz @@ -1292,6 +1366,7 @@ youngz yuche yuezk yui <1151815317@qq.com> +yykoypj <601924094@qq.com> z zack zefeng @@ -1308,6 +1383,7 @@ zhao-huo-long zhaocai zhaopeidong zhenfan.yu +zhengjitf zhuguibiao <505418722@qq.com> zhujun24 zhyupe @@ -1317,16 +1393,19 @@ zj9495 zkwolf zlljqn zollero -zombiej zongzi531 zoomdong <1344492820@qq.com> +zpc7 zqran ztplz +zty zuiidea zx6658 zxyao zytjs +zz <2418184580@qq.com> °))))彡 +Ömer Faruk APLAK Ștefan Filip रोहन मल्होत्रा 一喵呜 @@ -1337,6 +1416,7 @@ zytjs 九思⚡⚡⚡ <2228429150@qq.com> 二哲 二手掉包工程师 +二货爱吃白萝卜 云剪者 <584518260@qq.com> 付引 何乐 @@ -1344,6 +1424,7 @@ zytjs 何锦余 佛门耶稣 信鑫-King +元凛 兼续 冷方冰 <664930912@qq.com> 刘红 @@ -1360,6 +1441,7 @@ zytjs 小哈husky <951565664@qq.com> 小菜 <645801890@qq.com> 小鹅鹅鹅 +尾宿君 山客 崔宏森 <948346354@qq.com> 广彬-梁 <326741518@qq.com> @@ -1384,6 +1466,7 @@ zytjs 柚子男 沐霖 <304647173@qq.com> 爱but的苍蝇 <354788473@qq.com> +王小王 王林涛 王浩 王集鹄 @@ -1391,6 +1474,7 @@ zytjs 白羊座小葛 砖家 砖家 <576679268@qq.com> +社长长 章鱼 竹尔 米老朱 @@ -1398,6 +1482,7 @@ zytjs 约修亚 <510448079@qq.com> 翁润雨 <593110501@qq.com> 臧甲彬 fadeaway <498497303@qq.com> +舜岳 <1277952981@qq.com> 苏秦 <646382806@qq.com> 英布 萧琚 @@ -1406,6 +1491,7 @@ zytjs 蔡伦 薛定谔的猫 薛定谔的猫 +行冥 <571748236@qq.com> 诸岳 诸岳 诸岳 @@ -1414,6 +1500,7 @@ zytjs 谭真 <736420282@qq.com> 超能刚哥 迷渡 +郑国庆 郑旭 <332171564@qq.com> 闲耘™ 陆离 @@ -1434,4 +1521,5 @@ zytjs 黄文鉴 黄斌 黑雨 +龙风 <455947455@qq.com> 龚方闻 \ No newline at end of file From 51b69283a436378040d7a1640b5b623584cd9df7 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Wed, 26 Oct 2022 14:47:33 +0800 Subject: [PATCH 23/23] test: update test case (#38217) * test: update test case * chore: udpate snapshot --- .../input/__tests__/__snapshots__/Password.test.tsx.snap | 4 ++-- components/input/__tests__/index.test.tsx | 3 +-- package.json | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/input/__tests__/__snapshots__/Password.test.tsx.snap b/components/input/__tests__/__snapshots__/Password.test.tsx.snap index 06c75164d8..90e6f477f4 100644 --- a/components/input/__tests__/__snapshots__/Password.test.tsx.snap +++ b/components/input/__tests__/__snapshots__/Password.test.tsx.snap @@ -80,7 +80,7 @@ exports[`Input.Password should change type when click 1`] = ` exports[`Input.Password should change type when click 2`] = ` { it('click outside should also get focus', () => { const { container } = render(} />); const onFocus = jest.spyOn(container.querySelector('input')!, 'focus'); - fireEvent.mouseDown(container.querySelector('.test-suffix')!); - fireEvent.mouseUp(container.querySelector('.test-suffix')!); + fireEvent.click(container.querySelector('.test-suffix')!); expect(onFocus).toHaveBeenCalled(); }); diff --git a/package.json b/package.json index f67de8f9a9..eca9e60aa1 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "rc-dropdown": "~4.0.0", "rc-field-form": "~1.27.0", "rc-image": "~5.7.0", - "rc-input": "~0.1.2", + "rc-input": "~0.1.3", "rc-input-number": "~7.3.9", "rc-mentions": "~1.10.0", "rc-menu": "~9.6.3",