Skip to content

Commit

Permalink
fix: Upload accessibility experience (ant-design#46432)
Browse files Browse the repository at this point in the history
* fix: Upload tab experience

* test: update snapshot

* fix lint
  • Loading branch information
afc163 authored Dec 30, 2023
1 parent 44d1b68 commit 8705640
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42270,8 +42270,6 @@ exports[`ConfigProvider components Upload configProvider 1`] = `
>
<span
class="config-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down Expand Up @@ -42368,7 +42366,6 @@ exports[`ConfigProvider components Upload configProvider componentDisabled 1`] =
>
<span
class="config-upload config-upload-disabled"
role="button"
>
<input
accept=""
Expand Down Expand Up @@ -42435,8 +42432,6 @@ exports[`ConfigProvider components Upload configProvider componentSize large 1`]
>
<span
class="config-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down Expand Up @@ -42533,8 +42528,6 @@ exports[`ConfigProvider components Upload configProvider componentSize middle 1`
>
<span
class="config-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down Expand Up @@ -42631,8 +42624,6 @@ exports[`ConfigProvider components Upload configProvider componentSize small 1`]
>
<span
class="config-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down Expand Up @@ -42729,8 +42720,6 @@ exports[`ConfigProvider components Upload normal 1`] = `
>
<span
class="ant-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down Expand Up @@ -42827,8 +42816,6 @@ exports[`ConfigProvider components Upload prefixCls 1`] = `
>
<span
class="prefix-Upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down
10 changes: 5 additions & 5 deletions components/form/__tests__/__snapshots__/demo-extend.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5184,15 +5184,17 @@ Array [
>
<span
class="ant-upload ant-upload-disabled"
role="button"
>
<input
accept=""
disabled=""
style="display: none;"
type="file"
/>
<div>
<button
style="border: 0px; background: none;"
type="button"
>
<span
aria-label="plus"
class="anticon anticon-plus"
Expand Down Expand Up @@ -5220,7 +5222,7 @@ Array [
>
Upload
</div>
</div>
</button>
</span>
</div>
</div>
Expand Down Expand Up @@ -21115,8 +21117,6 @@ exports[`renders components/form/demo/validate-other.tsx extend context correctl
>
<span
class="ant-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down
10 changes: 5 additions & 5 deletions components/form/__tests__/__snapshots__/demo.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2718,15 +2718,17 @@ Array [
>
<span
class="ant-upload ant-upload-disabled"
role="button"
>
<input
accept=""
disabled=""
style="display:none"
type="file"
/>
<div>
<button
style="border:0;background:none"
type="button"
>
<span
aria-label="plus"
class="anticon anticon-plus"
Expand Down Expand Up @@ -2754,7 +2756,7 @@ Array [
>
Upload
</div>
</div>
</button>
</span>
</div>
</div>
Expand Down Expand Up @@ -9675,8 +9677,6 @@ exports[`renders components/form/demo/validate-other.tsx correctly 1`] = `
>
<span
class="ant-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@ exports[`Form form should support disabled 1`] = `
>
<span
class="ant-upload ant-upload-disabled"
role="button"
>
<input
accept=""
Expand Down
4 changes: 2 additions & 2 deletions components/form/demo/disabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ const FormDisabledDemo: React.FC = () => {
</Form.Item>
<Form.Item label="Upload" valuePropName="fileList" getValueFromEvent={normFile}>
<Upload action="/upload.do" listType="picture-card">
<div>
<button style={{ border: 0, background: 'none' }} type="button">
<PlusOutlined />
<div style={{ marginTop: 8 }}>Upload</div>
</div>
</button>
</Upload>
</Form.Item>
<Form.Item label="Button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ exports[`renders components/space/demo/base.tsx extend context correctly 1`] = `
>
<span
class="ant-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down
2 changes: 0 additions & 2 deletions components/space/__tests__/__snapshots__/demo.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ exports[`renders components/space/demo/base.tsx correctly 1`] = `
>
<span
class="ant-upload"
role="button"
tabindex="0"
>
<input
accept=""
Expand Down
10 changes: 8 additions & 2 deletions components/upload/Dragger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import type { UploadProps } from './interface';
export type DraggerProps = UploadProps & { height?: number };

const Dragger = React.forwardRef<UploadRef, DraggerProps>(
({ style, height, ...restProps }, ref) => (
<Upload ref={ref} {...restProps} type="drag" style={{ ...style, height }} />
({ style, height, hasControlInside = false, ...restProps }, ref) => (
<Upload
ref={ref}
hasControlInside={hasControlInside}
{...restProps}
type="drag"
style={{ ...style, height }}
/>
),
);

Expand Down
2 changes: 2 additions & 0 deletions components/upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
maxCount,
data = {},
multiple = false,
hasControlInside = true,
action = '',
accept = '',
supportServerRender = true,
Expand Down Expand Up @@ -350,6 +351,7 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
disabled: mergedDisabled,
beforeUpload: mergedBeforeUpload,
onChange: undefined,
hasControlInside,
} as RcUploadProps;

delete rcUploadProps.className;
Expand Down
Loading

0 comments on commit 8705640

Please sign in to comment.