Skip to content

Commit

Permalink
fix(kinput): add aria label to associate helper text with input [KHCP…
Browse files Browse the repository at this point in the history
…-11030] (#2138)

* fix(kinput): add aria label to associate helper text with input [KHCP-11030]

* fix(kinput): always generate helpTextID but only assign when helpText exists
  • Loading branch information
vaibhavrajsingh2001 authored and adamdehaven committed Jun 15, 2024
1 parent 75791f4 commit c287675
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/KInput/KInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<!-- TODO: [beta] change input class to text-input -->
<input
v-bind="modifiedAttrs"
:aria-describedby="helpText ? helpTextId : undefined"
:aria-invalid="error || hasError || charLimitExceeded ? 'true' : undefined"
class="k-input"
:value="getValue()"
Expand All @@ -56,6 +57,7 @@
>
<p
v-if="helpText"
:id="helpTextId"
:key="String(helpTextKey)"
class="help-text"
>
Expand Down Expand Up @@ -144,6 +146,7 @@ const attrs = useAttrs()
const isRequired = computed((): boolean => attrs?.required !== undefined && String(attrs?.required) !== 'false')
const inputId = computed((): string => attrs.id ? String(attrs.id) : uuidv4())
const helpTextId = uuidv4()
const strippedLabel = computed((): string => stripRequiredLabel(props.label, isRequired.value))
const hasLabelTooltip = computed((): boolean => !!(props.labelAttributes?.info || slots['label-tooltip']))
Expand Down

0 comments on commit c287675

Please sign in to comment.