Skip to content

fix(BBBToggle)!: expose correct accessible name, description and role - #95

Open
Arthurk12 wants to merge 1 commit into
bigbluebutton:developfrom
Arthurk12:issue/88
Open

Arthurk12 wants to merge 1 commit into
bigbluebutton:developfrom
Arthurk12:issue/88

Conversation

@Arthurk12

@Arthurk12 Arthurk12 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

The aria-label/aria-labelledby/aria-describedby props are passed to the MUI Switch root, which forwards them to the ButtonBase span instead of the . The input is then named by the that wraps both the title and the helper text, so its accessible name contains both texts and it has no description. MUI's Switch also renders a plain checkbox, so screen readers announce "checkbox" instead of "switch".

Pass the aria attributes and role="switch" through slotProps.input so they land on the , merging any slotProps.input supplied by the consumer (object or function form). Since aria-labelledby takes precedence over the native in the accessible name computation, the name becomes the title only and the helper text becomes the description. The keeps wrapping both texts, so clicking the helper text still toggles the switch; moving the helper text out of the label was discarded because it drops that behavior.

slotProps.input is used instead of inputProps because inputProps is deprecated in MUI and removed in v7. MUI does not merge the two (a slotProps.input replaces inputProps entirely), so a consumer's inputProps would be silently dropped; remove it from ToggleProps instead, turning that into a compile error. Merging the legacy prop was discarded because reading it keeps the deprecated API in use.

When only helperText is given, nothing provides aria-labelledby, so the names the input from the helper text; linking it as aria-describedby too would announce it twice. Link the helper as the description only when ariaLabel, ariaLabelledBy or label provides the name.

Switch only forwards slotProps.input to the since MUI 6.4.9 (earlier 6.x releases ignore it, or lack its types and
SwitchOwnerState), so raise the @mui/material and @mui/icons-material peer floor to 6.4.9.

BREAKING CHANGE: BBBToggle no longer accepts inputProps; use slotProps.input to set attributes on the underlying . The @mui/material and @mui/icons-material peer range is raised to ^6.4.9 || ^7.0.0.

Closes Issue(s)

Closes #88

@germanocaumo germanocaumo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the fix does nothing on MUI 6.1.4–6.4.5, which the peer range still allows.

suggestion: raise the peer to ^6.4.9 || ^7.0.0 in this already-breaking release and name the new floor in the BREAKING CHANGE footer.

Comment thread src/components/Toggle/component.tsx
The aria-label/aria-labelledby/aria-describedby props are passed to
the MUI Switch root, which forwards them to the ButtonBase span
instead of the <input>. The input is then named by the <label htmlFor>
that wraps both the title and the helper text, so its accessible name
contains both texts and it has no description. MUI's Switch also
renders a plain checkbox, so screen readers announce "checkbox"
instead of "switch".

Pass the aria attributes and role="switch" through slotProps.input so
they land on the <input>, merging any slotProps.input supplied by the
consumer (object or function form). Since aria-labelledby takes
precedence over the native <label> in the accessible name
computation, the name becomes the title only and the helper text
becomes the description. The <label htmlFor> keeps wrapping both
texts, so clicking the helper text still toggles the switch; moving
the helper text out of the label was discarded because it drops that
behavior.

slotProps.input is used instead of inputProps because inputProps is
deprecated in MUI and removed in v7. MUI does not merge the two (a
slotProps.input replaces inputProps entirely), so a consumer's
inputProps would be silently dropped; remove it from ToggleProps
instead, turning that into a compile error. Merging the legacy prop
was discarded because reading it keeps the deprecated API in use.

When only helperText is given, nothing provides aria-labelledby, so
the <label htmlFor> names the input from the helper text; linking it
as aria-describedby too would announce it twice. Link the helper as
the description only when ariaLabel, ariaLabelledBy or label provides
the name.

Switch only forwards slotProps.input to the <input> since MUI 6.4.9
(earlier 6.x releases ignore it, or lack its types and
SwitchOwnerState), so raise the @mui/material and @mui/icons-material
peer floor to 6.4.9.

BREAKING CHANGE: BBBToggle no longer accepts inputProps; use
slotProps.input to set attributes on the underlying <input>. The
@mui/material and @mui/icons-material peer range is raised to
^6.4.9 || ^7.0.0.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants