Skip to content

Commit

Permalink
[#524] Added aria-labelledby to the input element
Browse files Browse the repository at this point in the history
Attribute aria-labelledby is added in order to reference multiple
elements on the page and define the final accessible name for the input
element.
  • Loading branch information
vaszig committed Oct 31, 2023
1 parent 418efd4 commit 5bae7cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/formio/templates/label.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<label
class="utrecht-form-label {{ctx.label.className}} {% if (ctx.component.validate.required && ctx.requiredFieldsWithAsterisk) { %}utrecht-form-label--openforms-required{% } %}"
for="{{ctx.instance.id}}-{{ctx.component.key}}"
id="label-{{ctx.instance.id}}-{{ctx.component.key}}"
>
{{ ctx.t(ctx.component.label, { _userInput: true }) }}
{% if (!ctx.component.validate.required && !ctx.requiredFieldsWithAsterisk) { %}
Expand Down
3 changes: 2 additions & 1 deletion src/formio/templates/text.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{{attr}}="{{ctx.input.attr[attr]}}"
{% } %}
id="{{ctx.instance.id}}-{{ctx.component.key}}"
aria-labelledby="label-{{ctx.instance.id}}-{{ctx.component.key}} {{ctx.instance.id}}-{{ctx.component.key}} suffix-{{ctx.instance.id}}-{{ctx.component.key}}"
>{{ctx.input.content}}</{{ctx.input.type}}>
{% if (ctx.component.showCharCount) { %}
<span class="charcount" ref="charcount"></span>
Expand All @@ -24,7 +25,7 @@
<span class="wordcount" ref="wordcount"></span>
{% } %}
{% if (ctx.suffix) { %}
<span class="{{ctx.ofPrefix}}input-container__affix {{ctx.ofPrefix}}input-container__affix--suffix" ref="suffix">
<span class="{{ctx.ofPrefix}}input-container__affix {{ctx.ofPrefix}}input-container__affix--suffix" ref="suffix" id="suffix-{{ctx.instance.id}}-{{ctx.component.key}}">
{% if(ctx.suffix instanceof HTMLElement){ %}
{{ ctx.t(ctx.suffix.outerHTML) }}
{% } else{ %}
Expand Down

0 comments on commit 5bae7cc

Please sign in to comment.