Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form): add ariaLabel to hidden form input. #11417

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/calcite-components/src/utils/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export interface FormComponent<T = any> extends FormOwner {
/** When true, this component's value will not be submitted in the form. */
disabled: boolean;

/** Text label. */
label?: string;

/**
* When true, form submit requests will enforce field requirement.
*
Expand Down Expand Up @@ -125,7 +128,7 @@ export interface FormComponent<T = any> extends FormOwner {
/**
* Hook for components to sync _extra_ props on the hidden input form element used for form-submitting.
*
* Note: The following props are set by default: disabled, hidden, name, required, value.
* Note: The following props are set by default: disabled, label, hidden, name, required, value.
*/
syncHiddenFormInput?: (input: HTMLInputElement) => void;
}
Expand Down Expand Up @@ -528,9 +531,10 @@ function defaultSyncHiddenFormInput(
input: HTMLInputElement,
value: string,
): void {
const { defaultValue, disabled, form, name, required } = component;
const { defaultValue, disabled, form, name, required, label } = component;

// keep in sync to prevent losing reset value
input.ariaLabel = label;
input.defaultValue = defaultValue;
input.disabled = disabled;
input.name = name;
Expand Down