From 0f87c9d2596bb49721eac0f779745d5553fcf3b5 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Tue, 29 Aug 2023 16:44:13 +0800 Subject: [PATCH 1/5] fix: Watermark should not crash if content is empty (#44501) --- components/watermark/__tests__/index.test.tsx | 19 +++++++++++++++++++ components/watermark/useClips.ts | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/components/watermark/__tests__/index.test.tsx b/components/watermark/__tests__/index.test.tsx index 8de5a7aaf21b..ef7182cdf3d0 100644 --- a/components/watermark/__tests__/index.test.tsx +++ b/components/watermark/__tests__/index.test.tsx @@ -16,10 +16,18 @@ describe('Watermark', () => { }); }); + beforeEach(() => { + jest.useFakeTimers(); + }); + afterAll(() => { mockSrcSet.mockRestore(); }); + afterEach(() => { + jest.useRealTimers(); + }); + it('The watermark should render successfully', () => { const { container } = render(); expect(container.querySelector('.watermark div')).toBeTruthy(); @@ -94,4 +102,15 @@ describe('Watermark', () => { await waitFor(() => expect(target).toBeTruthy()); expect(container).toMatchSnapshot(); }); + + it('should not crash if content is empty string', async () => { + const spy = jest.spyOn(CanvasRenderingContext2D.prototype, 'drawImage'); + render(); + await waitFakeTimer(); + expect(spy).not.toHaveBeenCalledWith(expect.anything(), 0, 0); + expect(spy).not.toHaveBeenCalledWith(expect.anything(), -0, 0); + expect(spy).not.toHaveBeenCalledWith(expect.anything(), -0, -0); + expect(spy).not.toHaveBeenCalledWith(expect.anything(), 0, -0); + spy.mockRestore(); + }); }); diff --git a/components/watermark/useClips.ts b/components/watermark/useClips.ts index 2392e67d6a88..c8c8843ab440 100644 --- a/components/watermark/useClips.ts +++ b/components/watermark/useClips.ts @@ -69,7 +69,9 @@ export default function useClips() { // Copy from `ctx` and rotate rCtx.translate(realMaxSize / 2, realMaxSize / 2); rCtx.rotate(angle); - rCtx.drawImage(canvas, -contentWidth / 2, -contentHeight / 2); + if (contentWidth > 0 && contentHeight > 0) { + rCtx.drawImage(canvas, -contentWidth / 2, -contentHeight / 2); + } // Get boundary of rotated text function getRotatePos(x: number, y: number) { From 9c494ab9101dd8fee2c22d33015073bbccba8e71 Mon Sep 17 00:00:00 2001 From: Konv Suu <2583695112@qq.com> Date: Tue, 29 Aug 2023 17:56:56 +0800 Subject: [PATCH 2/5] fix: transfer label height (#44471) --- components/transfer/style/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/transfer/style/index.ts b/components/transfer/style/index.ts index 54e01e3e0182..cb6ffd25e2f8 100644 --- a/components/transfer/style/index.ts +++ b/components/transfer/style/index.ts @@ -305,6 +305,11 @@ const genTransferListStyle: GenerateStyle = (token: TransferToken '&-footer': { borderTop: `${lineWidth}px ${lineType} ${colorSplit}`, }, + + // fix: https://github.com/ant-design/ant-design/issues/44489 + '&-checkbox': { + lineHeight: 1, + }, }; }; From 8d7dd801201f2d2af5b1b30b67a432eaeab8d90c 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: Tue, 29 Aug 2023 18:47:41 +0800 Subject: [PATCH 3/5] docs: Update batch of docs & demos (#44509) * docs: update select opt * docs: update form deps demo * docs: upload onChange * docs: update form nest Form.List demo --- .../__snapshots__/demo-extend.test.ts.snap | 455 ++++++++++-------- .../__snapshots__/demo.test.tsx.snap | 371 +++++++++----- components/form/demo/dep-debug.md | 7 - components/form/demo/dep-debug.tsx | 31 -- components/form/demo/dependencies.md | 7 + components/form/demo/dependencies.tsx | 57 +++ .../form/demo/dynamic-form-items-complex.md | 4 +- .../form/demo/dynamic-form-items-complex.tsx | 131 +++-- components/form/index.en-US.md | 6 +- components/form/index.zh-CN.md | 6 +- components/select/demo/search.tsx | 8 +- components/select/index.en-US.md | 4 +- components/select/index.zh-CN.md | 2 +- components/upload/index.en-US.md | 4 +- components/upload/index.zh-CN.md | 4 +- 15 files changed, 622 insertions(+), 475 deletions(-) delete mode 100644 components/form/demo/dep-debug.md delete mode 100644 components/form/demo/dep-debug.tsx create mode 100644 components/form/demo/dependencies.md create mode 100644 components/form/demo/dependencies.tsx diff --git a/components/form/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/form/__tests__/__snapshots__/demo-extend.test.ts.snap index 58fc51ffbd40..1e18f3cceb2c 100644 --- a/components/form/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/form/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -2434,6 +2434,142 @@ exports[`renders components/form/demo/customized-form-controls.tsx extend contex exports[`renders components/form/demo/customized-form-controls.tsx extend context correctly 2`] = `[]`; +exports[`renders components/form/demo/dependencies.tsx extend context correctly 1`] = ` +
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+

+ Only Update when + + password2 + + updated: +

+
+      {}
+    
+
+
+`; + +exports[`renders components/form/demo/dependencies.tsx extend context correctly 2`] = `[]`; + exports[`renders components/form/demo/disabled.tsx extend context correctly 1`] = ` Array [