feat: Input fields in error are missing multiple ARIA attributes (#36762)

* feat: add implementation and update snapshots

* test: update snapshot

* test: update snapshots

* test: update snapshots

* test: update snapshots
This commit is contained in:
Uladzimir Atroshchanka 2022-08-24 13:07:50 +04:00 committed by GitHub
parent 58ae7821a7
commit c9fd7fb8f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 347 additions and 8 deletions

View File

@ -600,6 +600,7 @@ HTMLCollection [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="name" id="name"
placeholder="Please enter user name" placeholder="Please enter user name"
@ -655,6 +656,7 @@ HTMLCollection [
http:// http://
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="url" id="url"
placeholder="Please enter url" placeholder="Please enter url"
@ -710,6 +712,7 @@ HTMLCollection [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -724,6 +727,7 @@ HTMLCollection [
aria-controls="owner_list" aria-controls="owner_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="owner_list" aria-owns="owner_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="owner" id="owner"
@ -887,6 +891,7 @@ HTMLCollection [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -901,6 +906,7 @@ HTMLCollection [
aria-controls="type_list" aria-controls="type_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="type_list" aria-owns="type_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="type" id="type"
@ -1069,6 +1075,7 @@ HTMLCollection [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -1083,6 +1090,7 @@ HTMLCollection [
aria-controls="approver_list" aria-controls="approver_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="approver_list" aria-owns="approver_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="approver" id="approver"
@ -1246,6 +1254,7 @@ HTMLCollection [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-picker ant-picker-range" class="ant-picker ant-picker-range"
style="width: 100%;" style="width: 100%;"
> >
@ -2470,6 +2479,7 @@ HTMLCollection [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<textarea <textarea
aria-required="true"
class="ant-input" class="ant-input"
id="description" id="description"
placeholder="please enter url description" placeholder="please enter url description"

View File

@ -29,6 +29,7 @@ function toErrorEntity(
} }
export interface ErrorListProps { export interface ErrorListProps {
fieldId?: string;
help?: React.ReactNode; help?: React.ReactNode;
helpStatus?: ValidateStatus; helpStatus?: ValidateStatus;
errors?: React.ReactNode[]; errors?: React.ReactNode[];
@ -43,6 +44,7 @@ export default function ErrorList({
errors = EMPTY_LIST, errors = EMPTY_LIST,
warnings = EMPTY_LIST, warnings = EMPTY_LIST,
className: rootClassName, className: rootClassName,
fieldId,
onVisibleChanged, onVisibleChanged,
}: ErrorListProps) { }: ErrorListProps) {
const { prefixCls } = React.useContext(FormItemPrefixContext); const { prefixCls } = React.useContext(FormItemPrefixContext);
@ -69,6 +71,12 @@ export default function ErrorList({
]; ];
}, [help, helpStatus, debounceErrors, debounceWarnings]); }, [help, helpStatus, debounceErrors, debounceWarnings]);
const helpProps: { id?: string } = {};
if (fieldId) {
helpProps.id = `${fieldId}_help`;
}
return ( return (
<CSSMotion <CSSMotion
motionDeadline={collapseMotion.motionDeadline} motionDeadline={collapseMotion.motionDeadline}
@ -81,8 +89,10 @@ export default function ErrorList({
return ( return (
<div <div
{...helpProps}
className={classNames(baseClassName, holderClassName, rootClassName)} className={classNames(baseClassName, holderClassName, rootClassName)}
style={holderStyle} style={holderStyle}
role="alert"
> >
<CSSMotionList <CSSMotionList
keys={fullKeyList} keys={fullKeyList}
@ -102,7 +112,6 @@ export default function ErrorList({
return ( return (
<div <div
key={key} key={key}
role="alert"
className={classNames(itemClassName, { className={classNames(itemClassName, {
[`${baseClassName}-${errorStatus}`]: errorStatus, [`${baseClassName}-${errorStatus}`]: errorStatus,
})} })}

View File

@ -37,11 +37,16 @@ interface MemoInputProps {
value: any; value: any;
update: any; update: any;
children: React.ReactNode; children: React.ReactNode;
childProps: any[];
} }
const MemoInput = React.memo( const MemoInput = React.memo(
({ children }: MemoInputProps) => children as JSX.Element, ({ children }: MemoInputProps) => children as JSX.Element,
(prev, next) => prev.value === next.value && prev.update === next.update, (prev, next) =>
prev.value === next.value &&
prev.update === next.update &&
prev.childProps.length === next.childProps.length &&
prev.childProps.every((value, index) => value === next.childProps[index]),
); );
export interface FormItemProps<Values = any> export interface FormItemProps<Values = any>
@ -305,6 +310,25 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
childProps.id = fieldId; childProps.id = fieldId;
} }
if (props.help || mergedErrors.length > 0 || mergedWarnings.length > 0 || props.extra) {
const describedbyArr = [];
if (props.help || mergedErrors.length > 0) {
describedbyArr.push(`${fieldId}_help`);
}
if (props.extra) {
describedbyArr.push(`${fieldId}_extra`);
}
childProps['aria-describedby'] = describedbyArr.join(' ');
}
if (mergedErrors.length > 0) {
childProps['aria-invalid'] = 'true';
}
if (isRequired) {
childProps['aria-required'] = 'true';
}
if (supportRef(children)) { if (supportRef(children)) {
childProps.ref = getItemRef(mergedName, children); childProps.ref = getItemRef(mergedName, children);
} }
@ -322,8 +346,19 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
}; };
}); });
// List of props that need to be watched for changes -> if changes are detected in MemoInput -> rerender
const watchingChildProps = [
childProps['aria-required'],
childProps['aria-invalid'],
childProps['aria-describedby'],
];
childNode = ( childNode = (
<MemoInput value={mergedControl[props.valuePropName || 'value']} update={children}> <MemoInput
value={mergedControl[props.valuePropName || 'value']}
update={children}
childProps={watchingChildProps}
>
{cloneElement(children, childProps)} {cloneElement(children, childProps)}
</MemoInput> </MemoInput>
); );

View File

@ -32,6 +32,7 @@ export interface FormItemInputProps {
extra?: React.ReactNode; extra?: React.ReactNode;
status?: ValidateStatus; status?: ValidateStatus;
help?: React.ReactNode; help?: React.ReactNode;
fieldId?: string;
} }
const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = props => { const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = props => {
@ -45,6 +46,7 @@ const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = pro
_internalItemRender: formItemRender, _internalItemRender: formItemRender,
extra, extra,
help, help,
fieldId,
marginBottom, marginBottom,
onErrorVisibleChanged, onErrorVisibleChanged,
} = props; } = props;
@ -72,6 +74,7 @@ const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = pro
<div style={{ display: 'flex', flexWrap: 'nowrap' }}> <div style={{ display: 'flex', flexWrap: 'nowrap' }}>
<FormItemPrefixContext.Provider value={formItemContext}> <FormItemPrefixContext.Provider value={formItemContext}>
<ErrorList <ErrorList
fieldId={fieldId}
errors={errors} errors={errors}
warnings={warnings} warnings={warnings}
help={help} help={help}
@ -84,9 +87,19 @@ const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = pro
</div> </div>
) : null; ) : null;
const extraProps: { id?: string } = {};
if (fieldId) {
extraProps.id = `${fieldId}_extra`;
}
// If extra = 0, && will goes wrong // If extra = 0, && will goes wrong
// 0&&error -> 0 // 0&&error -> 0
const extraDom = extra ? <div className={`${baseClassName}-extra`}>{extra}</div> : null; const extraDom = extra ? (
<div {...extraProps} className={`${baseClassName}-extra`}>
{extra}
</div>
) : null;
const dom = const dom =
formItemRender && formItemRender.mark === 'pro_table_render' && formItemRender.render ? ( formItemRender && formItemRender.mark === 'pro_table_render' && formItemRender.render ? (

View File

@ -41,6 +41,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-0" id="advanced_search_field-0"
placeholder="placeholder" placeholder="placeholder"
@ -84,6 +85,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -98,6 +100,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
aria-controls="advanced_search_field-1_list" aria-controls="advanced_search_field-1_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="advanced_search_field-1_list" aria-owns="advanced_search_field-1_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="advanced_search_field-1" id="advanced_search_field-1"
@ -262,6 +265,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-2" id="advanced_search_field-2"
placeholder="placeholder" placeholder="placeholder"
@ -305,6 +309,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-3" id="advanced_search_field-3"
placeholder="placeholder" placeholder="placeholder"
@ -348,6 +353,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -362,6 +368,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
aria-controls="advanced_search_field-4_list" aria-controls="advanced_search_field-4_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="advanced_search_field-4_list" aria-owns="advanced_search_field-4_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="advanced_search_field-4" id="advanced_search_field-4"
@ -526,6 +533,7 @@ exports[`renders ./components/form/demo/advanced-search.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-5" id="advanced_search_field-5"
placeholder="placeholder" placeholder="placeholder"
@ -631,6 +639,7 @@ exports[`renders ./components/form/demo/basic.md extend context correctly 1`] =
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="basic_username" id="basic_username"
type="text" type="text"
@ -672,6 +681,7 @@ exports[`renders ./components/form/demo/basic.md extend context correctly 1`] =
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="basic_password" id="basic_password"
type="password" type="password"
@ -815,6 +825,7 @@ Array [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="basic_username" id="basic_username"
type="text" type="text"
@ -856,6 +867,7 @@ Array [
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="basic_password" id="basic_password"
type="password" type="password"
@ -1184,6 +1196,7 @@ Array [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="responsive_username" id="responsive_username"
type="text" type="text"
@ -1225,6 +1238,7 @@ Array [
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="responsive_password" id="responsive_password"
type="password" type="password"
@ -1601,6 +1615,7 @@ exports[`renders ./components/form/demo/control-hooks.md extend context correctl
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="control-hooks_note" id="control-hooks_note"
type="text" type="text"
@ -1638,6 +1653,7 @@ exports[`renders ./components/form/demo/control-hooks.md extend context correctl
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow"
> >
<div <div
@ -1652,6 +1668,7 @@ exports[`renders ./components/form/demo/control-hooks.md extend context correctl
aria-controls="control-hooks_gender_list" aria-controls="control-hooks_gender_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="control-hooks_gender_list" aria-owns="control-hooks_gender_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="control-hooks_gender" id="control-hooks_gender"
@ -1879,6 +1896,7 @@ exports[`renders ./components/form/demo/control-ref.md extend context correctly
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="control-ref_note" id="control-ref_note"
type="text" type="text"
@ -1916,6 +1934,7 @@ exports[`renders ./components/form/demo/control-ref.md extend context correctly
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow"
> >
<div <div
@ -1930,6 +1949,7 @@ exports[`renders ./components/form/demo/control-ref.md extend context correctly
aria-controls="control-ref_gender_list" aria-controls="control-ref_gender_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="control-ref_gender_list" aria-owns="control-ref_gender_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="control-ref_gender" id="control-ref_gender"
@ -5972,6 +5992,7 @@ exports[`renders ./components/form/demo/dynamic-form-items-complex.md extend con
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -5986,6 +6007,7 @@ exports[`renders ./components/form/demo/dynamic-form-items-complex.md extend con
aria-controls="dynamic_form_nest_item_area_list" aria-controls="dynamic_form_nest_item_area_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="dynamic_form_nest_item_area_list" aria-owns="dynamic_form_nest_item_area_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="dynamic_form_nest_item_area" id="dynamic_form_nest_item_area"
@ -6347,6 +6369,7 @@ exports[`renders ./components/form/demo/dynamic-rule.md extend context correctly
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="dynamic_rule_username" id="dynamic_rule_username"
placeholder="Please input your name" placeholder="Please input your name"
@ -6497,6 +6520,7 @@ exports[`renders ./components/form/demo/form-context.md extend context correctly
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="basicForm_group" id="basicForm_group"
type="text" type="text"
@ -6648,6 +6672,7 @@ Array [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="global_state_username" id="global_state_username"
type="text" type="text"
@ -6721,6 +6746,7 @@ exports[`renders ./components/form/demo/inline-login.md extend context correctly
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="horizontal_login_username" id="horizontal_login_username"
placeholder="Username" placeholder="Username"
@ -6775,6 +6801,7 @@ exports[`renders ./components/form/demo/inline-login.md extend context correctly
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="horizontal_login_password" id="horizontal_login_password"
placeholder="Password" placeholder="Password"
@ -7209,6 +7236,7 @@ exports[`renders ./components/form/demo/layout-can-wrap.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="wrap_username" id="wrap_username"
type="text" type="text"
@ -7248,6 +7276,7 @@ exports[`renders ./components/form/demo/layout-can-wrap.md extend context correc
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="wrap_password" id="wrap_password"
type="text" type="text"
@ -7333,6 +7362,7 @@ exports[`renders ./components/form/demo/nest-messages.md extend context correctl
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="nest-messages_user_name" id="nest-messages_user_name"
type="text" type="text"
@ -7635,6 +7665,7 @@ exports[`renders ./components/form/demo/normal-login.md extend context correctly
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="normal_login_username" id="normal_login_username"
placeholder="Username" placeholder="Username"
@ -7689,6 +7720,7 @@ exports[`renders ./components/form/demo/normal-login.md extend context correctly
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="normal_login_password" id="normal_login_password"
placeholder="Password" placeholder="Password"
@ -7902,6 +7934,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_email" id="register_email"
type="text" type="text"
@ -7943,6 +7976,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="register_password" id="register_password"
type="password" type="password"
@ -8012,6 +8046,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="register_confirm" id="register_confirm"
type="password" type="password"
@ -8124,6 +8159,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_nickname" id="register_nickname"
type="text" type="text"
@ -8161,6 +8197,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-cascader ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow" class="ant-select ant-cascader ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow"
> >
<div <div
@ -8174,6 +8211,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
aria-controls="register_residence_list" aria-controls="register_residence_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="register_residence_list" aria-owns="register_residence_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="register_residence" id="register_residence"
@ -8521,6 +8559,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
</div> </div>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_phone" id="register_phone"
type="text" type="text"
@ -8631,6 +8670,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
class="ant-input-number-input-wrap" class="ant-input-number-input-wrap"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-input-number-input" class="ant-input-number-input"
id="register_donation" id="register_donation"
@ -8818,6 +8858,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search" class="ant-select ant-select-in-form-item ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search"
> >
<div <div
@ -8832,6 +8873,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
aria-controls="register_website_list" aria-controls="register_website_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="register_website_list" aria-owns="register_website_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-input ant-select-selection-search-input" class="ant-input ant-select-selection-search-input"
id="register_website" id="register_website"
@ -8897,6 +8939,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
data-count="0 / 100" data-count="0 / 100"
> >
<textarea <textarea
aria-required="true"
class="ant-input" class="ant-input"
id="register_intro" id="register_intro"
/> />
@ -8933,6 +8976,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -8947,6 +8991,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
aria-controls="register_gender_list" aria-controls="register_gender_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="register_gender_list" aria-owns="register_gender_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="register_gender" id="register_gender"
@ -9129,6 +9174,7 @@ exports[`renders ./components/form/demo/register.md extend context correctly 1`]
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_captcha" id="register_captcha"
type="text" type="text"
@ -10986,6 +11032,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_date-picker" id="time_related_controls_date-picker"
placeholder="Select date" placeholder="Select date"
@ -11611,6 +11658,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_date-time-picker" id="time_related_controls_date-time-picker"
placeholder="Select date" placeholder="Select date"
@ -13589,6 +13637,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_month-picker" id="time_related_controls_month-picker"
placeholder="Select month" placeholder="Select month"
@ -13844,6 +13893,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-picker ant-picker-range" class="ant-picker ant-picker-range"
> >
<div <div
@ -15054,6 +15104,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-picker ant-picker-range" class="ant-picker ant-picker-range"
> >
<div <div
@ -17085,6 +17136,7 @@ exports[`renders ./components/form/demo/time-related-controls.md extend context
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_time-picker" id="time_related_controls_time-picker"
placeholder="Select time" placeholder="Select time"
@ -18748,6 +18800,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-has-feedback ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-has-feedback ant-select-single ant-select-show-arrow"
> >
<div <div
@ -18762,6 +18815,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
aria-controls="validate_other_select_list" aria-controls="validate_other_select_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="validate_other_select_list" aria-owns="validate_other_select_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="validate_other_select" id="validate_other_select"
@ -18920,6 +18974,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-multiple ant-select-show-search" class="ant-select ant-select-in-form-item ant-select-multiple ant-select-show-search"
> >
<div <div
@ -18942,6 +18997,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
aria-controls="validate_other_select-multiple_list" aria-controls="validate_other_select-multiple_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="validate_other_select-multiple_list" aria-owns="validate_other_select-multiple_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="validate_other_select-multiple" id="validate_other_select-multiple"
@ -19475,6 +19531,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-radio-group ant-radio-group-outline" class="ant-radio-group ant-radio-group-outline"
id="validate_other_radio-button" id="validate_other_radio-button"
> >
@ -20094,6 +20151,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
> >
<input <input
accept="" accept=""
aria-describedby="validate_other_upload_extra"
id="validate_other_upload" id="validate_other_upload"
style="display:none" style="display:none"
type="file" type="file"
@ -20135,6 +20193,7 @@ exports[`renders ./components/form/demo/validate-other.md extend context correct
</div> </div>
<div <div
class="ant-form-item-extra" class="ant-form-item-extra"
id="validate_other_upload_extra"
> >
longgggggggggggggggggggggggggggggggggg longgggggggggggggggggggggggggggggggggg
</div> </div>
@ -26406,6 +26465,7 @@ exports[`renders ./components/form/demo/warning-only.md extend context correctly
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="url" id="url"
placeholder="input placeholder" placeholder="input placeholder"

View File

@ -41,6 +41,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-0" id="advanced_search_field-0"
placeholder="placeholder" placeholder="placeholder"
@ -84,6 +85,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -98,6 +100,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
aria-controls="advanced_search_field-1_list" aria-controls="advanced_search_field-1_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="advanced_search_field-1_list" aria-owns="advanced_search_field-1_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="advanced_search_field-1" id="advanced_search_field-1"
@ -180,6 +183,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-2" id="advanced_search_field-2"
placeholder="placeholder" placeholder="placeholder"
@ -223,6 +227,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-3" id="advanced_search_field-3"
placeholder="placeholder" placeholder="placeholder"
@ -266,6 +271,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -280,6 +286,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
aria-controls="advanced_search_field-4_list" aria-controls="advanced_search_field-4_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="advanced_search_field-4_list" aria-owns="advanced_search_field-4_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="advanced_search_field-4" id="advanced_search_field-4"
@ -362,6 +369,7 @@ exports[`renders ./components/form/demo/advanced-search.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="advanced_search_field-5" id="advanced_search_field-5"
placeholder="placeholder" placeholder="placeholder"
@ -467,6 +475,7 @@ exports[`renders ./components/form/demo/basic.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="basic_username" id="basic_username"
type="text" type="text"
@ -508,6 +517,7 @@ exports[`renders ./components/form/demo/basic.md correctly 1`] = `
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="basic_password" id="basic_password"
type="password" type="password"
@ -651,6 +661,7 @@ Array [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="basic_username" id="basic_username"
type="text" type="text"
@ -692,6 +703,7 @@ Array [
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="basic_password" id="basic_password"
type="password" type="password"
@ -913,6 +925,7 @@ Array [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="responsive_username" id="responsive_username"
type="text" type="text"
@ -954,6 +967,7 @@ Array [
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="responsive_password" id="responsive_password"
type="password" type="password"
@ -1223,6 +1237,7 @@ exports[`renders ./components/form/demo/control-hooks.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="control-hooks_note" id="control-hooks_note"
type="text" type="text"
@ -1260,6 +1275,7 @@ exports[`renders ./components/form/demo/control-hooks.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow"
> >
<div <div
@ -1274,6 +1290,7 @@ exports[`renders ./components/form/demo/control-hooks.md correctly 1`] = `
aria-controls="control-hooks_gender_list" aria-controls="control-hooks_gender_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="control-hooks_gender_list" aria-owns="control-hooks_gender_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="control-hooks_gender" id="control-hooks_gender"
@ -1402,6 +1419,7 @@ exports[`renders ./components/form/demo/control-ref.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="control-ref_note" id="control-ref_note"
type="text" type="text"
@ -1439,6 +1457,7 @@ exports[`renders ./components/form/demo/control-ref.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow"
> >
<div <div
@ -1453,6 +1472,7 @@ exports[`renders ./components/form/demo/control-ref.md correctly 1`] = `
aria-controls="control-ref_gender_list" aria-controls="control-ref_gender_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="control-ref_gender_list" aria-owns="control-ref_gender_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="control-ref_gender" id="control-ref_gender"
@ -3455,6 +3475,7 @@ exports[`renders ./components/form/demo/dynamic-form-items-complex.md correctly
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -3469,6 +3490,7 @@ exports[`renders ./components/form/demo/dynamic-form-items-complex.md correctly
aria-controls="dynamic_form_nest_item_area_list" aria-controls="dynamic_form_nest_item_area_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="dynamic_form_nest_item_area_list" aria-owns="dynamic_form_nest_item_area_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="dynamic_form_nest_item_area" id="dynamic_form_nest_item_area"
@ -3748,6 +3770,7 @@ exports[`renders ./components/form/demo/dynamic-rule.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="dynamic_rule_username" id="dynamic_rule_username"
placeholder="Please input your name" placeholder="Please input your name"
@ -3898,6 +3921,7 @@ exports[`renders ./components/form/demo/form-context.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="basicForm_group" id="basicForm_group"
type="text" type="text"
@ -4049,6 +4073,7 @@ Array [
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="global_state_username" id="global_state_username"
type="text" type="text"
@ -4122,6 +4147,7 @@ exports[`renders ./components/form/demo/inline-login.md correctly 1`] = `
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="horizontal_login_username" id="horizontal_login_username"
placeholder="Username" placeholder="Username"
@ -4176,6 +4202,7 @@ exports[`renders ./components/form/demo/inline-login.md correctly 1`] = `
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="horizontal_login_password" id="horizontal_login_password"
placeholder="Password" placeholder="Password"
@ -4610,6 +4637,7 @@ exports[`renders ./components/form/demo/layout-can-wrap.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="wrap_username" id="wrap_username"
type="text" type="text"
@ -4649,6 +4677,7 @@ exports[`renders ./components/form/demo/layout-can-wrap.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="wrap_password" id="wrap_password"
type="text" type="text"
@ -4734,6 +4763,7 @@ exports[`renders ./components/form/demo/nest-messages.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="nest-messages_user_name" id="nest-messages_user_name"
type="text" type="text"
@ -5036,6 +5066,7 @@ exports[`renders ./components/form/demo/normal-login.md correctly 1`] = `
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="normal_login_username" id="normal_login_username"
placeholder="Username" placeholder="Username"
@ -5090,6 +5121,7 @@ exports[`renders ./components/form/demo/normal-login.md correctly 1`] = `
</span> </span>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="normal_login_password" id="normal_login_password"
placeholder="Password" placeholder="Password"
@ -5303,6 +5335,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_email" id="register_email"
type="text" type="text"
@ -5344,6 +5377,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="register_password" id="register_password"
type="password" type="password"
@ -5413,6 +5447,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
> >
<input <input
action="click" action="click"
aria-required="true"
class="ant-input" class="ant-input"
id="register_confirm" id="register_confirm"
type="password" type="password"
@ -5501,6 +5536,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_nickname" id="register_nickname"
type="text" type="text"
@ -5538,6 +5574,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-cascader ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow" class="ant-select ant-cascader ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow"
> >
<div <div
@ -5551,6 +5588,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
aria-controls="register_residence_list" aria-controls="register_residence_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="register_residence_list" aria-owns="register_residence_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="register_residence" id="register_residence"
@ -5726,6 +5764,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
</div> </div>
</span> </span>
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_phone" id="register_phone"
type="text" type="text"
@ -5836,6 +5875,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
class="ant-input-number-input-wrap" class="ant-input-number-input-wrap"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-input-number-input" class="ant-input-number-input"
id="register_donation" id="register_donation"
@ -5941,6 +5981,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search" class="ant-select ant-select-in-form-item ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search"
> >
<div <div
@ -5955,6 +5996,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
aria-controls="register_website_list" aria-controls="register_website_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="register_website_list" aria-owns="register_website_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-input ant-select-selection-search-input" class="ant-input ant-select-selection-search-input"
id="register_website" id="register_website"
@ -6006,6 +6048,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
data-count="0 / 100" data-count="0 / 100"
> >
<textarea <textarea
aria-required="true"
class="ant-input" class="ant-input"
id="register_intro" id="register_intro"
/> />
@ -6042,6 +6085,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-single ant-select-show-arrow"
> >
<div <div
@ -6056,6 +6100,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
aria-controls="register_gender_list" aria-controls="register_gender_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="register_gender_list" aria-owns="register_gender_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="register_gender" id="register_gender"
@ -6139,6 +6184,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
style="padding-left:4px;padding-right:4px" style="padding-left:4px;padding-right:4px"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="register_captcha" id="register_captcha"
type="text" type="text"
@ -7186,6 +7232,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_date-picker" id="time_related_controls_date-picker"
placeholder="Select date" placeholder="Select date"
@ -7257,6 +7304,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_date-time-picker" id="time_related_controls_date-time-picker"
placeholder="Select date" placeholder="Select date"
@ -7328,6 +7376,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_month-picker" id="time_related_controls_month-picker"
placeholder="Select month" placeholder="Select month"
@ -7393,6 +7442,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-picker ant-picker-range" class="ant-picker ant-picker-range"
> >
<div <div
@ -7506,6 +7556,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-picker ant-picker-range" class="ant-picker ant-picker-range"
> >
<div <div
@ -7625,6 +7676,7 @@ exports[`renders ./components/form/demo/time-related-controls.md correctly 1`] =
class="ant-picker-input" class="ant-picker-input"
> >
<input <input
aria-required="true"
autocomplete="off" autocomplete="off"
id="time_related_controls_time-picker" id="time_related_controls_time-picker"
placeholder="Select time" placeholder="Select time"
@ -7923,6 +7975,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-has-feedback ant-select-single ant-select-show-arrow" class="ant-select ant-select-in-form-item ant-select-has-feedback ant-select-single ant-select-show-arrow"
> >
<div <div
@ -7937,6 +7990,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
aria-controls="validate_other_select_list" aria-controls="validate_other_select_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="validate_other_select_list" aria-owns="validate_other_select_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="validate_other_select" id="validate_other_select"
@ -8013,6 +8067,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-multiple ant-select-show-search" class="ant-select ant-select-in-form-item ant-select-multiple ant-select-show-search"
> >
<div <div
@ -8035,6 +8090,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
aria-controls="validate_other_select-multiple_list" aria-controls="validate_other_select-multiple_list"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-owns="validate_other_select-multiple_list" aria-owns="validate_other_select-multiple_list"
aria-required="true"
autocomplete="off" autocomplete="off"
class="ant-select-selection-search-input" class="ant-select-selection-search-input"
id="validate_other_select-multiple" id="validate_other_select-multiple"
@ -8463,6 +8519,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<div <div
aria-required="true"
class="ant-radio-group ant-radio-group-outline" class="ant-radio-group ant-radio-group-outline"
id="validate_other_radio-button" id="validate_other_radio-button"
> >
@ -9082,6 +9139,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
> >
<input <input
accept="" accept=""
aria-describedby="validate_other_upload_extra"
id="validate_other_upload" id="validate_other_upload"
style="display:none" style="display:none"
type="file" type="file"
@ -9123,6 +9181,7 @@ exports[`renders ./components/form/demo/validate-other.md correctly 1`] = `
</div> </div>
<div <div
class="ant-form-item-extra" class="ant-form-item-extra"
id="validate_other_upload_extra"
> >
longgggggggggggggggggggggggggggggggggg longgggggggggggggggggggggggggggggggggg
</div> </div>
@ -11063,6 +11122,7 @@ exports[`renders ./components/form/demo/warning-only.md correctly 1`] = `
class="ant-form-item-control-input-content" class="ant-form-item-control-input-content"
> >
<input <input
aria-required="true"
class="ant-input" class="ant-input"
id="url" id="url"
placeholder="input placeholder" placeholder="input placeholder"

View File

@ -203,6 +203,158 @@ describe('Form', () => {
); );
}); });
it('input element should have the prop aria-describedby pointing to the help id when there is a help message', () => {
const wrapper = mount(
<Form>
<Form.Item name="test" help="This is a help">
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-describedby')).toBe('test_help');
const help = wrapper.find('.ant-form-item-explain');
expect(help.prop('id')).toBe('test_help');
});
it('input element should not have the prop aria-describedby pointing to the help id when there is a help message and name is not defined', () => {
const wrapper = mount(
<Form>
<Form.Item help="This is a help">
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-describedby')).toBeUndefined();
const help = wrapper.find('.ant-form-item-explain');
expect(help.prop('id')).toBeUndefined();
});
it('input element should have the prop aria-describedby concatenated with the form name pointing to the help id when there is a help message', () => {
const wrapper = mount(
<Form name="form">
<Form.Item name="test" help="This is a help">
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-describedby')).toBe('form_test_help');
const help = wrapper.find('.ant-form-item-explain');
expect(help.prop('id')).toBe('form_test_help');
});
it('input element should have the prop aria-describedby pointing to the help id when there are errors', async () => {
const wrapper = mount(
<Form>
<Form.Item name="test" rules={[{ len: 3 }, { type: 'number' }]}>
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: 'Invalid number' } });
await sleep(800);
wrapper.update();
const inputChanged = wrapper.find('input');
expect(inputChanged.prop('aria-describedby')).toBe('test_help');
const help = wrapper.find('.ant-form-item-explain');
expect(help.prop('id')).toBe('test_help');
});
it('input element should have the prop aria-invalid when there are errors', async () => {
const wrapper = mount(
<Form>
<Form.Item name="test" rules={[{ len: 3 }, { type: 'number' }]}>
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: 'Invalid number' } });
await sleep(800);
wrapper.update();
const inputChanged = wrapper.find('input');
expect(inputChanged.prop('aria-invalid')).toBe('true');
});
it('input element should have the prop aria-required when the prop `required` is true', async () => {
const wrapper = mount(
<Form>
<Form.Item name="test" required>
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-required')).toBe('true');
});
it('input element should have the prop aria-required when there is a rule with required', async () => {
const wrapper = mount(
<Form>
<Form.Item name="test" rules={[{ required: true }]}>
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-required')).toBe('true');
});
it('input element should have the prop aria-describedby pointing to the extra id when there is a extra message', () => {
const wrapper = mount(
<Form>
<Form.Item name="test" extra="This is a extra message">
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-describedby')).toBe('test_extra');
const extra = wrapper.find('.ant-form-item-extra');
expect(extra.prop('id')).toBe('test_extra');
});
it('input element should not have the prop aria-describedby pointing to the extra id when there is a extra message and name is not defined', () => {
const wrapper = mount(
<Form>
<Form.Item extra="This is a extra message">
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-describedby')).toBeUndefined();
const extra = wrapper.find('.ant-form-item-extra');
expect(extra.prop('id')).toBeUndefined();
});
it('input element should have the prop aria-describedby pointing to the help and extra id when there is a help and extra message', () => {
const wrapper = mount(
<Form>
<Form.Item name="test" help="This is a help" extra="This is a extra message">
<input />
</Form.Item>
</Form>,
);
const input = wrapper.find('input');
expect(input.prop('aria-describedby')).toBe('test_help test_extra');
});
describe('scrollToField', () => { describe('scrollToField', () => {
function test(name, genForm) { function test(name, genForm) {
it(name, () => { it(name, () => {
@ -710,9 +862,7 @@ describe('Form', () => {
await sleep(100); await sleep(100);
wrapper.update(); wrapper.update();
await sleep(100); await sleep(100);
expect(wrapper.find('.ant-form-item-explain div').getDOMNode().getAttribute('role')).toBe( expect(wrapper.find('.ant-form-item-explain').getDOMNode().getAttribute('role')).toBe('alert');
'alert',
);
}); });
it('return same form instance', () => { it('return same form instance', () => {

View File

@ -112,6 +112,7 @@ exports[`renders ./components/mentions/demo/form.md extend context correctly 1`]
class="ant-mentions" class="ant-mentions"
> >
<textarea <textarea
aria-required="true"
class="rc-textarea" class="rc-textarea"
id="bio" id="bio"
placeholder="You can use @ to ref user here" placeholder="You can use @ to ref user here"

View File

@ -112,6 +112,7 @@ exports[`renders ./components/mentions/demo/form.md correctly 1`] = `
class="ant-mentions" class="ant-mentions"
> >
<textarea <textarea
aria-required="true"
class="rc-textarea" class="rc-textarea"
id="bio" id="bio"
placeholder="You can use @ to ref user here" placeholder="You can use @ to ref user here"

View File

@ -120,7 +120,7 @@ return <Menu items={items} />;
#### SubMenuType #### SubMenuType
| 参数 | 说明 | 类型 | 默认值 | 版本 | | 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| children | 子菜单的菜单项 | [ItemType\[\]](#ItemType) | - | | | children | 子菜单的菜单项 | [ItemType\[\]](#ItemType) | - | |
| disabled | 是否禁用 | boolean | false | | | disabled | 是否禁用 | boolean | false | |
| icon | 菜单图标 | ReactNode | - | | | icon | 菜单图标 | ReactNode | - | |