Skip to content

label-has-for does not handle binding for attribute #119

Closed
@bertmckay79

Description

@bertmckay79

When using attribute binding to associate the for attribute the plugin does not detect rasies the label-has-for error

This use case is typical when creating enterprise component libraries.

Below is an example of a textbox where the id is being passed as a prop:

<template>
  <div
    class="form-group"
    :class="invalid ?'form-group-error' : ''"
  >
    <h3
      v-if="labeltext"
      class="label-wrapper"
    >
      <label
        :id="`lbl${uniqueid}`"
        class="input-label"
        :for="uniqueid"
      >
        {{ labeltext }}
      </label>
    </h3>
    <div
      v-if="helptext"
      :id="`${uniqueid}-hint`"
      class="govuk-hint"
    >
      {{ helptext }}
    </div>
    <span
      v-if="invalid"
      id="event-name-error"
      class="input-error-message"
    >
      <span class="sr-only">Error:</span> {{ validationtext }}
    </span>
    <input
      :id="uniqueid"
      :name="uniqueid"
      v-bind="$attrs"
     :type="text"
      :value="value"
      :aria-labelledby="`lbl${uniqueid}`"
      :aria-describedby="helptext ? `${uniqueid}-hint` : undefined"
      :autocomplete="autocomplete"
      @input="$emit('input', $event.target.value)"
    >
  </div>
</template>

<script>
export default {
  name: 'Textbox',
  props: {
    uniqueid: {
      type: String,
      required: true
    }
....
}
</script>

Would it be possible to handle this?
Thanks
Bert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions