Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(SELECT): Aria-labelledby got empty space when no mat-label is defined and shows accessibility error in WAVE #22192

Closed
talamaska opened this issue Mar 11, 2021 · 1 comment · Fixed by #22251
Assignees
Labels
Accessibility This issue is related to accessibility (a11y) area: material/select P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@talamaska
Copy link

talamaska commented Mar 11, 2021

Reproduction

Use StackBlitz to reproduce your issue:

Steps to reproduce:

  1. inspect the mat-select
  2. see the aria-labelledby
  3. check source code
    in select
  /** Gets the aria-labelledby for the select panel. */
  _getPanelAriaLabelledby(): string | null {
    if (this.ariaLabel) {
      return null;
    }

    const labelId = this._getLabelId();
    return this.ariaLabelledby ? labelId + ' ' + this.ariaLabelledby : labelId;
  }

and in form-field

  /**
   * Gets the id of the label element. If no label is present, returns `null`.
   */
  getLabelId(): string|null {
    return this._hasFloatingLabel() ? this._labelId : null;
  }

labelIed can be null so we end up with null + ' ' + ariaLabelledby or null
The only way to overcome this behavior is to provide our own aria-label
But that's more like a workaround.

Expected Behavior

No empty space before the concatenated parts of the string.
I think there should be null check before adding space infornt of the other string.

Actual Behavior

There is an empty space before the value of the attribute.

image

This breaks the accessibility tested with WAVE addon

Environment

  • Angular: 10.x
  • CDK/Material: 10.2.7
  • Browser(s): Chrome latest
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Verfied that the same ource code logic exist in v11 so it must be valid for v11 aswell

@talamaska talamaska added the needs triage This issue needs to be triaged by the team label Mar 11, 2021
@crisbeto crisbeto added Accessibility This issue is related to accessibility (a11y) area: material/select P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Mar 15, 2021
@crisbeto crisbeto self-assigned this Mar 16, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 16, 2021
If the form field doesn't have a label, we can end up with an `aria-labelledby` which has a leading
space. This appears to be flagged as invalid by some a11y tools.

Fixes angular#22192.
andrewseguin pushed a commit that referenced this issue Mar 19, 2021
If the form field doesn't have a label, we can end up with an `aria-labelledby` which has a leading
space. This appears to be flagged as invalid by some a11y tools.

Fixes #22192.
andrewseguin pushed a commit that referenced this issue Mar 19, 2021
If the form field doesn't have a label, we can end up with an `aria-labelledby` which has a leading
space. This appears to be flagged as invalid by some a11y tools.

Fixes #22192.

(cherry picked from commit 9b67d67)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) area: material/select P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants