From 1a27f476b7616395f44e205a029fcecd375a12c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:51:52 +0800 Subject: [PATCH 1/6] chore(deps): bump actions/upload-artifact from 4 to 5 (#55708) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/preview-build.yml | 4 ++-- .github/workflows/site-deploy.yml | 2 +- .github/workflows/test-v6.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- .github/workflows/visual-regression-diff-build.yml | 6 +++--- .github/workflows/visual-regression-persist-start.yml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 3aef729a43..119b35a46f 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -30,7 +30,7 @@ jobs: - name: run e2e test run: bun run test:site - name: upload site artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: site path: _site/ @@ -42,7 +42,7 @@ jobs: - name: Upload PR number if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: pr path: ./pr-id.txt diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml index 97e0161882..295237570a 100644 --- a/.github/workflows/site-deploy.yml +++ b/.github/workflows/site-deploy.yml @@ -45,7 +45,7 @@ jobs: fi - name: upload site artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: real-site path: _site/ diff --git a/.github/workflows/test-v6.yml b/.github/workflows/test-v6.yml index eaf057afe1..7f136f28f2 100644 --- a/.github/workflows/test-v6.yml +++ b/.github/workflows/test-v6.yml @@ -76,7 +76,7 @@ jobs: mkdir persist-coverage mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 name: upload coverages with: name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }} @@ -179,7 +179,7 @@ jobs: run: bun run test:dekko # Artifact build files - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 if: github.event_name == 'push' && github.ref == 'refs/heads/master' with: name: build artifacts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b2a82b890..65a2749b98 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,7 +79,7 @@ jobs: mkdir persist-coverage mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 name: upload coverages with: name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }} @@ -182,7 +182,7 @@ jobs: run: bun run test:dekko # Artifact build files - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 if: github.event_name == 'push' && github.ref == 'refs/heads/master' with: name: build artifacts diff --git a/.github/workflows/visual-regression-diff-build.yml b/.github/workflows/visual-regression-diff-build.yml index 0fc06a3d9d..bd8a11b8ef 100644 --- a/.github/workflows/visual-regression-diff-build.yml +++ b/.github/workflows/visual-regression-diff-build.yml @@ -37,7 +37,7 @@ jobs: env: NODE_OPTIONS: --max_old_space_size=4096 - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 name: artifact snapshot with: name: snapshot-artifacts-${{ strategy.job-index }} @@ -71,7 +71,7 @@ jobs: # Upload report in `visualRegressionReport` - name: upload report artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 if: ${{ always() }} with: name: visual-regression-report @@ -85,7 +85,7 @@ jobs: - name: Upload persist key if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: visual-regression-diff-ref path: ./visual-regression-pr-id.txt diff --git a/.github/workflows/visual-regression-persist-start.yml b/.github/workflows/visual-regression-persist-start.yml index 6356ad9a48..77939f5ccf 100644 --- a/.github/workflows/visual-regression-persist-start.yml +++ b/.github/workflows/visual-regression-persist-start.yml @@ -31,7 +31,7 @@ jobs: # Upload `imageSnapshots` on master - name: upload report artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: image-snapshots path: imageSnapshots.tar.gz @@ -43,7 +43,7 @@ jobs: - name: Upload persist key if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: visual-regression-ref path: ./visual-regression-ref.txt From d731b4db9478b380a2197a648b6f1b6f7f0afde3 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Thu, 13 Nov 2025 22:18:49 +0800 Subject: [PATCH 2/6] chore(deps): Revert "chore(deps): bump actions/upload-artifact from 4 to 5 (#55708)" (#55710) --- .github/workflows/preview-build.yml | 4 ++-- .github/workflows/site-deploy.yml | 2 +- .github/workflows/test-v6.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- .github/workflows/visual-regression-diff-build.yml | 6 +++--- .github/workflows/visual-regression-persist-start.yml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 119b35a46f..3aef729a43 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -30,7 +30,7 @@ jobs: - name: run e2e test run: bun run test:site - name: upload site artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: site path: _site/ @@ -42,7 +42,7 @@ jobs: - name: Upload PR number if: ${{ always() }} - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: pr path: ./pr-id.txt diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml index 295237570a..97e0161882 100644 --- a/.github/workflows/site-deploy.yml +++ b/.github/workflows/site-deploy.yml @@ -45,7 +45,7 @@ jobs: fi - name: upload site artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: real-site path: _site/ diff --git a/.github/workflows/test-v6.yml b/.github/workflows/test-v6.yml index 7f136f28f2..eaf057afe1 100644 --- a/.github/workflows/test-v6.yml +++ b/.github/workflows/test-v6.yml @@ -76,7 +76,7 @@ jobs: mkdir persist-coverage mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json - - uses: actions/upload-artifact@v5 + - uses: actions/upload-artifact@v4 name: upload coverages with: name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }} @@ -179,7 +179,7 @@ jobs: run: bun run test:dekko # Artifact build files - - uses: actions/upload-artifact@v5 + - uses: actions/upload-artifact@v4 if: github.event_name == 'push' && github.ref == 'refs/heads/master' with: name: build artifacts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65a2749b98..1b2a82b890 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,7 +79,7 @@ jobs: mkdir persist-coverage mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json - - uses: actions/upload-artifact@v5 + - uses: actions/upload-artifact@v4 name: upload coverages with: name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }} @@ -182,7 +182,7 @@ jobs: run: bun run test:dekko # Artifact build files - - uses: actions/upload-artifact@v5 + - uses: actions/upload-artifact@v4 if: github.event_name == 'push' && github.ref == 'refs/heads/master' with: name: build artifacts diff --git a/.github/workflows/visual-regression-diff-build.yml b/.github/workflows/visual-regression-diff-build.yml index bd8a11b8ef..0fc06a3d9d 100644 --- a/.github/workflows/visual-regression-diff-build.yml +++ b/.github/workflows/visual-regression-diff-build.yml @@ -37,7 +37,7 @@ jobs: env: NODE_OPTIONS: --max_old_space_size=4096 - - uses: actions/upload-artifact@v5 + - uses: actions/upload-artifact@v4 name: artifact snapshot with: name: snapshot-artifacts-${{ strategy.job-index }} @@ -71,7 +71,7 @@ jobs: # Upload report in `visualRegressionReport` - name: upload report artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: visual-regression-report @@ -85,7 +85,7 @@ jobs: - name: Upload persist key if: ${{ always() }} - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: visual-regression-diff-ref path: ./visual-regression-pr-id.txt diff --git a/.github/workflows/visual-regression-persist-start.yml b/.github/workflows/visual-regression-persist-start.yml index 77939f5ccf..6356ad9a48 100644 --- a/.github/workflows/visual-regression-persist-start.yml +++ b/.github/workflows/visual-regression-persist-start.yml @@ -31,7 +31,7 @@ jobs: # Upload `imageSnapshots` on master - name: upload report artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: image-snapshots path: imageSnapshots.tar.gz @@ -43,7 +43,7 @@ jobs: - name: Upload persist key if: ${{ always() }} - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: visual-regression-ref path: ./visual-regression-ref.txt From d903180635aa223e9a3b4126ff8122c68b882686 Mon Sep 17 00:00:00 2001 From: GeekerGx <386348903@qq.com> Date: Fri, 14 Nov 2025 07:09:09 +0800 Subject: [PATCH 3/6] docs: update API type (#55671) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Upload API添加类型说明 beforeUpload 中的参数file, fileList没有指明类型,会和UploadFile混淆,导致开发中出现意料外的情况 Signed-off-by: GeekerGx <386348903@qq.com> * Update components/upload/index.zh-CN.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: GeekerGx <386348903@qq.com> --------- Signed-off-by: GeekerGx <386348903@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- components/upload/index.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/upload/index.zh-CN.md b/components/upload/index.zh-CN.md index b8f0bc5a84..5f69d17e82 100644 --- a/components/upload/index.zh-CN.md +++ b/components/upload/index.zh-CN.md @@ -53,7 +53,7 @@ demo: | --- | --- | --- | --- | --- | | accept | 接受上传的文件类型,详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) | string | - | | | action | 上传的地址 | string \| (file) => Promise<string> | - | | -| beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传( resolve 传入 `File` 或 `Blob` 对象则上传 resolve 传入对象);也可以返回 `Upload.LIST_IGNORE`,此时列表中将不展示此文件。 **注意:IE9 不支持该方法** | (file, fileList) => boolean \| Promise<File> \| `Upload.LIST_IGNORE` | - | | +| beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传( resolve 传入 `File` 或 `Blob` 对象则上传 resolve 传入对象);也可以返回 `Upload.LIST_IGNORE`,此时列表中将不展示此文件。 **注意:IE9 不支持该方法** | (file: RcFile, fileList: RcFile[]) => boolean \| Promise<File> \| `Upload.LIST_IGNORE` | - | | | customRequest | 通过覆盖默认的上传行为,可以自定义自己的上传实现 | ( options: [RequestOptions](#request-options), info: { defaultRequest: (option: [RequestOptions](#request-options)) => void; } ) => void | - | defaultRequest: 5.28.0 | | data | 上传所需额外参数或返回上传额外参数的方法 | object\|(file) => object \| Promise<object> | - | | | defaultFileList | 默认已经上传的文件列表 | object\[] | - | | From 3f644af0fb288f8a010ad498c39cf501a64d90da Mon Sep 17 00:00:00 2001 From: GeekerGx <386348903@qq.com> Date: Fri, 14 Nov 2025 11:20:43 +0800 Subject: [PATCH 4/6] docs: improve upload api doc (#55714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Upload API添加类型说明 补充修改英文文档 参考:中文文档修改记录 https://github.com/ant-design/ant-design/pull/55671 Signed-off-by: GeekerGx <386348903@qq.com> * chore: update doc * Apply suggestion from @meet-student Signed-off-by: 遇见同学 <1875694521@qq.com> * Apply suggestion from @meet-student Signed-off-by: 遇见同学 <1875694521@qq.com> * chore: update * chore: update snap --------- Signed-off-by: GeekerGx <386348903@qq.com> Signed-off-by: 遇见同学 <1875694521@qq.com> Co-authored-by: 遇见同学 <1875694521@qq.com> --- components/upload/index.en-US.md | 13 +++++++++++-- components/upload/index.zh-CN.md | 13 +++++++++++-- scripts/__snapshots__/check-site.ts.snap | 4 ++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/components/upload/index.en-US.md b/components/upload/index.en-US.md index d9a5b043f9..f8a0ba5820 100644 --- a/components/upload/index.en-US.md +++ b/components/upload/index.en-US.md @@ -52,7 +52,7 @@ Common props ref:[Common props](/docs/react/common-props) | --- | --- | --- | --- | --- | | accept | File types that can be accepted. See [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) | string | - | | | action | Uploading URL | string \| (file) => Promise<string> | - | | -| beforeUpload | Hook function which will be executed before uploading. Uploading will be stopped with `false` or a rejected Promise returned. When returned value is `Upload.LIST_IGNORE`, the list of files that have been uploaded will ignore it. **Warning:this function is not supported in IE9** | (file, fileList) => boolean \| Promise<File> \| `Upload.LIST_IGNORE` | - | | +| beforeUpload | Hook function which will be executed before uploading. Uploading will be stopped with `false` or a rejected Promise returned. When returned value is `Upload.LIST_IGNORE`, the list of files that have been uploaded will ignore it. **Warning:this function is not supported in IE9** | (file: [RcFile](#rcfile), fileList: [RcFile[]](#rcfile)) => boolean \| Promise<File> \| `Upload.LIST_IGNORE` | - | | | customRequest | Override for the default xhr behavior allowing for additional customization and the ability to implement your own XMLHttpRequest | ( options: [RequestOptions](#request-options), info: { defaultRequest: (option: [RequestOptions](#request-options)) => void; } ) => void | - | defaultRequest: 5.28.0 | | data | Uploading extra params or function which can return uploading extra params | object \| (file) => object \| Promise<object> | - | | | defaultFileList | Default list of files that have been uploaded | object\[] | - | | @@ -80,9 +80,18 @@ Common props ref:[Common props](/docs/react/common-props) | onPreview | A callback function, will be executed when the file link or preview icon is clicked | function(file) | - | | | onRemove | A callback function, will be executed when removing file button is clicked, remove event will be prevented when the return value is false or a Promise which resolve(false) or reject | function(file): boolean \| Promise | - | | +### RcFile + +Extends [File](https://developer.mozilla.org/en-US/docs/Web/API/File). + +| Property | Description | Type | Default | Version | +| --- | --- | --- | --- | --- | +| uid | unique id. Will auto-generate when not provided | string | - | - | +| lastModifiedDate | A Date object indicating the date and time at which the file was last modified | date | - | - | + ### UploadFile -Extends File with additional props. +Extends [File](https://developer.mozilla.org/en-US/docs/Web/API/File) with additional props. | Property | Description | Type | Default | Version | | --- | --- | --- | --- | --- | diff --git a/components/upload/index.zh-CN.md b/components/upload/index.zh-CN.md index 5f69d17e82..60c3a03de8 100644 --- a/components/upload/index.zh-CN.md +++ b/components/upload/index.zh-CN.md @@ -53,7 +53,7 @@ demo: | --- | --- | --- | --- | --- | | accept | 接受上传的文件类型,详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) | string | - | | | action | 上传的地址 | string \| (file) => Promise<string> | - | | -| beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传( resolve 传入 `File` 或 `Blob` 对象则上传 resolve 传入对象);也可以返回 `Upload.LIST_IGNORE`,此时列表中将不展示此文件。 **注意:IE9 不支持该方法** | (file: RcFile, fileList: RcFile[]) => boolean \| Promise<File> \| `Upload.LIST_IGNORE` | - | | +| beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传( resolve 传入 `File` 或 `Blob` 对象则上传 resolve 传入对象);也可以返回 `Upload.LIST_IGNORE`,此时列表中将不展示此文件。 **注意:IE9 不支持该方法** | (file: [RcFile](#rcfile), fileList: [RcFile[]](#rcfile)) => boolean \| Promise<File> \| `Upload.LIST_IGNORE` | - | | | customRequest | 通过覆盖默认的上传行为,可以自定义自己的上传实现 | ( options: [RequestOptions](#request-options), info: { defaultRequest: (option: [RequestOptions](#request-options)) => void; } ) => void | - | defaultRequest: 5.28.0 | | data | 上传所需额外参数或返回上传额外参数的方法 | object\|(file) => object \| Promise<object> | - | | | defaultFileList | 默认已经上传的文件列表 | object\[] | - | | @@ -81,9 +81,18 @@ demo: | onPreview | 点击文件链接或预览图标时的回调 | function(file) | - | | | onRemove   | 点击移除文件时的回调,返回值为 false 时不移除。支持返回一个 Promise 对象,Promise 对象 resolve(false) 或 reject 时不移除               | function(file): boolean \| Promise | -   | | +### RcFile + +继承自 [File](https://developer.mozilla.org/zh-CN/docs/Web/API/File)。 + +| 参数 | 说明 | 类型 | 默认值 | 版本 | +| ---------------- | ------------------------------ | ------ | ------ | ---- | +| uid | 唯一标识符,不设置时会自动生成 | string | - | - | +| lastModifiedDate | 上次修改文件的日期和时间 | date | - | - | + ### UploadFile -继承自 File,附带额外属性用于渲染。 +继承自 [File](https://developer.mozilla.org/zh-CN/docs/Web/API/File),附带额外属性用于渲染。 | 参数 | 说明 | 类型 | 默认值 | 版本 | | --- | --- | --- | --- | --- | diff --git a/scripts/__snapshots__/check-site.ts.snap b/scripts/__snapshots__/check-site.ts.snap index 6c1bba4905..1554579e3d 100644 --- a/scripts/__snapshots__/check-site.ts.snap +++ b/scripts/__snapshots__/check-site.ts.snap @@ -268,9 +268,9 @@ exports[`site test Component components/typography en Page 1`] = `6`; exports[`site test Component components/typography zh Page 1`] = `6`; -exports[`site test Component components/upload en Page 1`] = `3`; +exports[`site test Component components/upload en Page 1`] = `4`; -exports[`site test Component components/upload zh Page 1`] = `3`; +exports[`site test Component components/upload zh Page 1`] = `4`; exports[`site test Component components/watermark en Page 1`] = `2`; From 4e19a1f3d2f173d5dc93601552413ed529bf5e40 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 11:31:57 +0800 Subject: [PATCH 5/6] chore(deps): disable Dependabot auto-upgrade for actions/upload-artifact@v4 (#55711) * chore(deps): Revert "chore(deps): bump actions/upload-artifact from 4 to 5 (#55708)" * Initial plan * chore: disable Dependabot auto-upgrade for actions/upload-artifact@v4 Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com> --------- Co-authored-by: thinkasany <480968828@qq.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com> --- .github/dependabot.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 42e7e4e9c1..2260f1f650 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -33,3 +33,6 @@ updates: - github-actions - dependencies - skip-verify-files + ignore: + - dependency-name: actions/upload-artifact + update-types: [version-update:semver-major] From 19a37a3780eeda939ac4ef0e2c13a06cdefa0321 Mon Sep 17 00:00:00 2001 From: x1ngYu <25836768@qq.com> Date: Fri, 14 Nov 2025 11:40:29 +0800 Subject: [PATCH 6/6] fix(drawer): improve accessibility (aria-labelledby) (#55697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 遇见同学 <1875694521@qq.com> Co-authored-by: thinkasany <480968828@qq.com> --- components/drawer/DrawerPanel.tsx | 9 +++-- components/drawer/__tests__/Drawer.test.tsx | 21 ++++++++++++ .../__snapshots__/Drawer.test.tsx.snap | 2 ++ .../__snapshots__/demo-extend.test.tsx.snap | 34 +++++++++++++++++++ components/drawer/index.tsx | 10 ++++-- 5 files changed, 72 insertions(+), 4 deletions(-) diff --git a/components/drawer/DrawerPanel.tsx b/components/drawer/DrawerPanel.tsx index dcc402370d..72efec5ed6 100644 --- a/components/drawer/DrawerPanel.tsx +++ b/components/drawer/DrawerPanel.tsx @@ -21,7 +21,7 @@ export interface DrawerStyles extends NonNullable { export interface DrawerPanelProps { prefixCls: string; - + ariaId?: string; title?: React.ReactNode; footer?: React.ReactNode; extra?: React.ReactNode; @@ -62,6 +62,7 @@ export interface DrawerPanelProps { const DrawerPanel: React.FC = (props) => { const { prefixCls, + ariaId, title, footer, extra, @@ -128,7 +129,11 @@ const DrawerPanel: React.FC = (props) => { >
{closablePlacement === 'start' && mergedCloseIcon} - {title &&
{title}
} + {title && ( +
+ {title} +
+ )}
{extra &&
{extra}
} {closablePlacement === 'end' && mergedCloseIcon} diff --git a/components/drawer/__tests__/Drawer.test.tsx b/components/drawer/__tests__/Drawer.test.tsx index 000ae79d74..0b7b6886fb 100644 --- a/components/drawer/__tests__/Drawer.test.tsx +++ b/components/drawer/__tests__/Drawer.test.tsx @@ -460,4 +460,25 @@ describe('Drawer', () => { // 添加快照断言 expect(container.firstChild).toMatchSnapshot(); }); + + it('should have aria-labelledby on drawer content when title is provided', () => { + const { baseElement, rerender } = render(Here is content of Drawer); + const content = baseElement.querySelector('.ant-drawer-content'); + expect(content).not.toHaveAttribute('aria-labelledby'); + + rerender( + + Here is content of Drawer + , + ); + const title = baseElement.querySelector('.ant-drawer-title'); + expect(content).toHaveAttribute('aria-labelledby', title?.getAttribute('id')); + + rerender( + + Here is content of Drawer + , + ); + expect(content).toHaveAttribute('aria-labelledby', 'custom-id'); + }); }); diff --git a/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap b/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap index 497dbea775..3f994c7302 100644 --- a/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +++ b/components/drawer/__tests__/__snapshots__/Drawer.test.tsx.snap @@ -379,6 +379,7 @@ exports[`Drawer have a title 1`] = ` style="width: 378px;" >