Skip to content

Commit

Permalink
Merge pull request #576 from open-formulieren/of-524/fix-input-access…
Browse files Browse the repository at this point in the history
…ibility-concerning-suffix

[#524] Improve input element accessibility
  • Loading branch information
sergei-maertens authored Oct 31, 2023
2 parents 418efd4 + af510ed commit 9feb83b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/formio/templates/label.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<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}}"
{% if (ctx.component.suffix) { %}
id="label-{{ctx.instance.id}}-{{ctx.component.key}}"
{% } %}
>
{{ ctx.t(ctx.component.label, { _userInput: true }) }}
{% if (!ctx.component.validate.required && !ctx.requiredFieldsWithAsterisk) { %}
Expand Down
5 changes: 4 additions & 1 deletion src/formio/templates/text.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
{{attr}}="{{ctx.input.attr[attr]}}"
{% } %}
id="{{ctx.instance.id}}-{{ctx.component.key}}"
{% if (ctx.suffix) { %}
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 +27,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 9feb83b

Please sign in to comment.