-
Notifications
You must be signed in to change notification settings - Fork 62
FORMS-18634: Desktop, RWD Tablet, RWD Mobile - Form field with error not identified @sunnym @vavarshn #1585
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,7 @@ class FormFieldBase extends FormField { | |
#syncLabel() { | ||
let labelElement = typeof this.getLabel === 'function' ? this.getLabel() : null; | ||
if (labelElement) { | ||
labelElement.setAttribute('id', `${this.getId()}__label`); | ||
labelElement.setAttribute('for', this.getWidgetId()); | ||
} | ||
} | ||
|
@@ -176,6 +177,7 @@ class FormFieldBase extends FormField { | |
let errorElement = typeof this.getErrorDiv === 'function' ? this.getErrorDiv() : null; | ||
if (errorElement) { | ||
errorElement.setAttribute('id', `${this.getId()}__errormessage`); | ||
errorElement.setAttribute('aria-describedby', `${this.getId()}__label`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is already present in the input field. We can not use the aria-describedby attribute on the error container. |
||
} | ||
} | ||
|
||
|
@@ -249,7 +251,7 @@ class FormFieldBase extends FormField { | |
this.#syncLabel() | ||
this.#syncWidget() | ||
this.#syncShortDesc() | ||
this. #syncLongDesc() | ||
this.#syncLongDesc() | ||
this.#syncAriaDescribedBy() | ||
this.#syncError() | ||
this.#syncAriaLabel() | ||
|
@@ -538,6 +540,8 @@ class FormFieldBase extends FormField { | |
// Check if the validationMessage is different from the current content | ||
if (this.errorDiv.innerHTML !== state.validationMessage) { | ||
this.errorDiv.innerHTML = state.validationMessage; | ||
this.errorDiv.removeAttribute('tabindex'); | ||
this.errorDiv.removeAttribute('role'); | ||
if (state.validity.valid === false) { | ||
// Find the first key whose value is true | ||
const validationType = Object.keys(state.validity).find(key => key !== 'valid' && state.validity[key] === true); | ||
|
@@ -550,7 +554,9 @@ class FormFieldBase extends FormField { | |
if (!state.validationMessage) { | ||
this.errorDiv.innerHTML = LanguageUtils.getTranslatedString(this.formContainer.getModel().lang, "defaultError"); | ||
} | ||
} | ||
this.errorDiv.setAttribute('tabindex', 0); | ||
this.errorDiv.setAttribute('role', 'complementary'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is usually incorrect to use role="complementary" on an error container. |
||
} | ||
this.#syncAriaDescribedBy(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this id