dcx-react-library icon indicating copy to clipboard operation
dcx-react-library copied to clipboard

Error <div /> rendered in formInput without no error

Open Ibabalola opened this issue 10 months ago • 0 comments

Describe the bug

  1. When rendering the form input, on page load the:
<div class="dcx-error-message"></div>

render also when there's not an error Expected behaviour is to render only when an error appear.

  1. Based on the GDS rules the container for the error message should be a p tag instead of a div tag as currently is.
<div class="dcx-error-message"></div>

needs to become:

<p class="dcx-error-message"></p>

A full example will be:

<div class="dcx-form-input  govuk-form-group govuk-form-group--error">
  <label class="govuk-label" for="national-insurance-number">
    National Insurance number
  </label>
  <div id="national-insurance-number-hint" class="govuk-hint">
    It’s on your National Insurance card, benefit letter, payslip or P60. For example, ‘QQ 12 34 56 C’.
  </div>
  <p id="national-insurance-number-error" class="dcx-error-message govuk-error-message">
    <span class="govuk-visually-hidden">Error:</span> Enter a National Insurance number in the correct format
  </p>
  <input class="govuk-input govuk-input--error" id="national-insurance-number" name="nationalInsuranceNumber" type="text" aria-describedby="national-insurance-number-hint national-insurance-number-error">
</div>
  1. For screen readers we need as well to provide:
 hiddenErrorText,
 hiddenErrorTextProps,

and it will behave like the following:

<p>
      <span {...hiddenErrorTextProps}>{hiddenErrorText}</span>{' '}{staticErrorMessage}
</p>

Ibabalola avatar Apr 19 '24 15:04 Ibabalola