From 39ca711cfab72e98668f68d26d8ff56ef772661f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 20 Oct 2021 11:18:08 +0800 Subject: [PATCH 1/4] chore(deps): update dependency http-server to v14 (#32568) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a4c559bbb..76cae50186 100644 --- a/package.json +++ b/package.json @@ -214,7 +214,7 @@ "fs-extra": "^10.0.0", "full-icu": "^1.3.0", "glob": "^7.1.4", - "http-server": "^13.0.0", + "http-server": "^14.0.0", "husky": "^7.0.1", "identity-obj-proxy": "^3.0.0", "ignore-emit-webpack-plugin": "^2.0.6", From 7d68eca271a4623b2474cdc6d435d6805aec8f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <7971419+crazyair@users.noreply.github.com> Date: Wed, 20 Oct 2021 12:23:56 +0800 Subject: [PATCH 2/4] docs: add doc (#32570) * feat: add doc --- components/form/index.zh-CN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/components/form/index.zh-CN.md b/components/form/index.zh-CN.md index c136af1b7a..f3966972e6 100644 --- a/components/form/index.zh-CN.md +++ b/components/form/index.zh-CN.md @@ -443,3 +443,4 @@ React 中异步更新会导致受控组件交互行为异常。当用户交互 ### 有更多参考文档吗? - 你可以阅读[《antd v4 Form 使用心得》](https://zhuanlan.zhihu.com/p/375753910)获得一些使用帮助以及建议。 +- 想在 DatePicker、Switch 也使用 before、after?可以参考[《如何优雅的对 Form.Item 的 children 增加 before、after》](https://zhuanlan.zhihu.com/p/422752055)。 From 38b94e5aebcd1d14d5fe4d9b3497cf52b8904a49 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 20 Oct 2021 18:19:20 +0800 Subject: [PATCH 3/4] fix: Transfer menu item key warning (#32578) * fix: Transfer menu item key warning close #32574 * chore: skip tree demo in UI test --- components/transfer/list.tsx | 4 ++++ components/tree/__tests__/image.test.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index 81906f3c23..9f05b620f0 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -370,6 +370,7 @@ export default class TransferList< {/* Remove Current Page */} {pagination && ( { const pageKeys = getEnabledItemKeys( (this.defaultListBodyRef.current?.getItems() || []).map(entity => entity.item), @@ -383,6 +384,7 @@ export default class TransferList< {/* Remove All */} { onItemRemove?.(getEnabledItemKeys(filteredItems)); }} @@ -395,6 +397,7 @@ export default class TransferList< menu = ( { const keys = getEnabledItemKeys(filteredItems); onItemSelectAll(keys, keys.length !== checkedKeys.length); @@ -413,6 +416,7 @@ export default class TransferList< )} { let availableKeys: string[]; if (pagination) { diff --git a/components/tree/__tests__/image.test.ts b/components/tree/__tests__/image.test.ts index 7d45a493e8..46a790c604 100644 --- a/components/tree/__tests__/image.test.ts +++ b/components/tree/__tests__/image.test.ts @@ -1,5 +1,5 @@ import { imageDemoTest } from '../../../tests/shared/imageTest'; describe('Tree image', () => { - imageDemoTest('tree', { skip: ['virtual-scroll.md'] }); + imageDemoTest('tree', { skip: ['virtual-scroll.md', 'big-data.md'] }); }); From 9fe5820cf0175c1df6f98948e949897c41cf6f43 Mon Sep 17 00:00:00 2001 From: hydraZty <670688667@qq.com> Date: Thu, 21 Oct 2021 13:22:13 +0800 Subject: [PATCH 4/4] fix: Typography ellipsis height error (#32496) --- components/typography/util.tsx | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/components/typography/util.tsx b/components/typography/util.tsx index 6ad6503bfe..f884cf0876 100644 --- a/components/typography/util.tsx +++ b/components/typography/util.tsx @@ -25,14 +25,6 @@ const wrapperStyle: React.CSSProperties = { lineHeight: 'inherit', }; -function pxToNumber(value: string | null): number { - if (!value) { - return 0; - } - const match = value.match(/^\d*(\.\d*)?/); - return match ? Number(match[0]) : 0; -} - function styleToString(style: CSSStyleDeclaration) { // There are some different behavior between Firefox & Chrome. // We have to handle this ourself. @@ -66,6 +58,10 @@ function resetDomStyles(target: HTMLElement, origin: HTMLElement) { target.style.height = 'auto'; target.style.minHeight = 'auto'; target.style.maxHeight = 'auto'; + target.style.paddingTop = '0'; + target.style.paddingBottom = '0'; + target.style.borderTopWidth = '0'; + target.style.borderBottomWidth = '0'; target.style.top = '-999999px'; target.style.zIndex = '-1000'; // clean up css overflow @@ -79,10 +75,11 @@ function getRealLineHeight(originElement: HTMLElement) { resetDomStyles(heightContainer, originElement); heightContainer.appendChild(document.createTextNode('text')); document.body.appendChild(heightContainer); - const { offsetHeight } = heightContainer; - const lineHeight = pxToNumber(window.getComputedStyle(originElement).lineHeight); + // The element real height is always less than multiple of line-height + // Use getBoundingClientRect to get actual single row height of the element + const realHeight = heightContainer.getBoundingClientRect().height; document.body.removeChild(heightContainer); - return offsetHeight > lineHeight ? offsetHeight : lineHeight; + return realHeight; } export default ( @@ -103,14 +100,8 @@ export default ( } const { rows, suffix = '' } = option; - // Get origin style - const originStyle = window.getComputedStyle(originElement); const lineHeight = getRealLineHeight(originElement); - const overflowRows = rows + 1; - const oneRowMaxHeight = - Math.floor(lineHeight) + - pxToNumber(originStyle.paddingTop) + - pxToNumber(originStyle.paddingBottom); + const maxHeight = Math.round(lineHeight * rows * 100 ) / 100; resetDomStyles(ellipsisContainer, originElement); @@ -129,9 +120,9 @@ export default ( // Check if ellipsis in measure div is height enough for content function inRange() { - return ( - Math.ceil(ellipsisContainer.getBoundingClientRect().height / overflowRows) < oneRowMaxHeight - ); + const currentHeight = + Math.round(ellipsisContainer.getBoundingClientRect().height * 100) / 100 + return currentHeight - .1 <= maxHeight; // -.1 for firefox } // Skip ellipsis if already match