a11y: add alert role when displaying errors in live validation (#76958) #1313

Open
fpeters wants to merge 1 commits from wip/76958-a11y-live-validation into main
Owner

De https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Alert_Role :

The most important thing to know about the alert role is that it's for content that is dynamically displayed, not for content that appears on page load. It is perfect for situations such as when a user fills out a form and JavaScript is used to add an error message - the alert would immediately read out the message. It should not be used on HTML that the user hasn't interacted with. For example, if a page loads with multiple visible alerts scattered throughout, the alert role should not be used, as the messages were not dynamically triggered.

Donc j'ajoute l'attribut lors de la validation live, pas dans le rendu "statique" de la page.

De https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Alert_Role : > The most important thing to know about the alert role is that it's for content that is dynamically displayed, not for content that appears on page load. It is perfect for situations such as when a user fills out a form and JavaScript is used to add an error message - the alert would immediately read out the message. It should not be used on HTML that the user hasn't interacted with. For example, if a page loads with multiple visible alerts scattered throughout, the alert role should not be used, as the messages were not dynamically triggered. Donc j'ajoute l'attribut lors de la validation live, pas dans le rendu "statique" de la page.
fpeters added 1 commit 2024-03-25 15:15:05 +01:00
gitea/wcs/pipeline/head There was a failure building this commit Details
c64bf82232
a11y: add alert role when displaying errors in live validation (#76958)
fpeters force-pushed wip/76958-a11y-live-validation from c64bf82232 to 928b9a66cb 2024-03-25 15:17:54 +01:00 Compare
fpeters reviewed 2024-03-25 15:18:52 +01:00
@ -1023,3 +1023,4 @@
const errorElMessage = document.getElementById(`error_${this.name}_${errorType}`).innerHTML
this.errorEl.setAttribute('role', 'alert')
this.errorEl.innerHTML = errorElMessage
Author
Owner

Posé avant de mettre le contenu, pour suivre la doc d'MDN qui dit :

Do not try to dynamically add/generate an element with role="alert" that is already populated with the alert message you want announced - this generally does not lead to an announcement, as it is not a content change.

Posé *avant* de mettre le contenu, pour suivre la doc d'MDN qui dit : > Do not try to dynamically add/generate an element with role="alert" that is already populated with the alert message you want announced - this generally does not lead to an announcement, as it is not a content change.
fpeters requested review from tjund 2024-04-03 16:34:35 +02:00
All checks were successful
gitea/wcs/pipeline/head This commit looks good
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: entrouvert/wcs#1313
No description provided.