Required asterisk is part of the accessible name of form controls

Open Beginner friendly
#600 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start in src/functional-components/form-control/form-control.scss and trace how the required label is rendered and referenced by aria-labelledby. The issue includes a Playwright reproduction for six-input and six-textarea; run that check and confirm their accessible names are Name while the required state remains exposed. The same label is used by several other components listed in the issue.

Written by the indexing model from the issue text.

Description

Six Webcomponents version

5.5.2 (reproduced on main at 4368add7e)

Steps to reproduce
  1. Render a required field:

    <six-input label="Name" required></six-input>
    <six-textarea label="Name" required></six-textarea>
    
  2. Inspect the inner <input> / <textarea> in the browser accessibility tree (DevTools > Elements > Accessibility > Computed Properties > Name).

Alternatively, the same check as a Playwright test, using the repository fixture (src/test-utils/fixtures):

for (const tag of ['six-input', 'six-textarea']) {
  test(`${tag} required label name`, async ({ page }) => {
    await page.setContent(`<${tag} label="Name" required></${tag}>`);
    await expect(page.getByRole('textbox')).toHaveAccessibleName('Name');
  });
}
What is expected?

The accessible name is the label text only: Name. The required state is already exposed through the native required attribute.

What is actually happening?

The accessible name is Name *, so screen readers read the asterisk as part of the field name.

Error: expect(locator).toHaveAccessibleName(expected) failed
Expected: "Name"
Received: "Name *"

The asterisk comes from CSS generated content on the <label> that is referenced by aria-labelledby, in src/functional-components/form-control/form-control.scss:

.form-control__label__required::after {
  content: '*';
  ...
}

The accessible name computation includes CSS ::before / ::after content (accname 1.2, step 2F.ii), so every component that renders FormControl with required is affected. Verified for six-input and six-textarea; six-select, six-checkbox, six-range, six-rating, six-switch and six-group-label use the same FormControl label.

Any additional comments?

Suggested fix: render the asterisk as a decorative element that is excluded from the accessible name, for example <span class="form-control__label__required" aria-hidden="true">*</span> inside the label, instead of the ::after pseudo-element. An alternative is CSS alternative text (content: '*' / ''), but browser support for it is not complete.

This is not a WCAG conformance failure: the computed name still contains the visible label (SC 2.5.3). The asterisk is a visual marker for the required state, which the native required attribute already exposes, so it duplicates that information in the field name.

Confirmed with Windows Narrator: the asterisk is read as part of the field name.

We found this in an Angular 21 application (@six-group/ui-library-angular 5.5.2) and reproduced it in this repository without any application code.

Dominant language
TypeScript
Stars
30
Forks
14
Avg merge
3d 5h
Merged PRs (30d)
5

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from six-group/six-webcomponents

All issues in six-group/six-webcomponents

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.