Skip to content

Conversation

@adolgachev
Copy link
Contributor

@adolgachev adolgachev commented Dec 5, 2025

Fixes a11y issues when no label is used, but the label wrapper (with an onclick) is still present. This can lead to an extra interactive tab-stop depending on the screen reader used.

Added option to explicitly hide the label.

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Dec 5, 2025
@adolgachev adolgachev changed the title feat(material/slide-togge): Add option to hide label feat(material/slide-toggle): Add option to completely hide label Dec 5, 2025
@adolgachev adolgachev added Accessibility This issue is related to accessibility (a11y) action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Dec 5, 2025
@adolgachev adolgachev marked this pull request as ready for review December 5, 2025 19:34
@pullapprove pullapprove bot requested review from mmalerba and ok7sai December 5, 2025 19:34
@adolgachev adolgachev added the action: global presubmit The PR is in need of a google3 global presubmit label Dec 5, 2025
@mmalerba mmalerba removed their request for review December 5, 2025 19:40
@pullapprove pullapprove bot requested a review from tjshiu December 5, 2025 19:40
@adolgachev adolgachev requested a review from crisbeto December 8, 2025 17:18
Clicking on the label will trigger another click event from the button.
Stop propagation here so other listeners further up in the DOM don't execute twice.
-->
<label class="mdc-label" [for]="buttonId" [attr.id]="_labelId" (click)="$event.stopPropagation()">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get the same with CSS like this?

label:empty {
  display: none;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I'll try that out. My concern was that click handler in the a11y tree which causes it to be marked as interactive with TalkBack even when we try to hide it. So just went with a more explicit approach. But let me test out what happens with just that css.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it works, the a11y tree shows it as hidden, and Android TB works okay. I wasn't able to exactly reproduce their issue but confident on this working too given that.

I originally thought about hiding label but continuing to use the content for aira-labelledby but it made it too messy, so if we just require the aria-label when empty, I think this is clearly better option.

@adolgachev adolgachev added dev-app preview When applied, previews of the dev-app are deployed to Firebase docs: preview When applied, a preview of the documentation site is deployed to Firebase labels Dec 8, 2025
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Deployed dev-app for 6b8cbb4 to: https://ng-dev-previews-comp--pr-angular-components-32480-dev-8wd8hfe4.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Deployed docs-preview for 6b8cbb4 to: https://ng-dev-previews-comp--pr-angular-components-32480-docs-jpaocuag.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would there be a mat-slide-toggle without a label? Are there good use cases for it? Should it just be removed instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Accessibility This issue is related to accessibility (a11y) action: global presubmit The PR is in need of a google3 global presubmit action: review The PR is still awaiting reviews from at least one requested reviewer area: material/slide-toggle detected: feature PR contains a feature commit dev-app preview When applied, previews of the dev-app are deployed to Firebase docs: preview When applied, a preview of the documentation site is deployed to Firebase target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants