Repository navigation
Conversation
chore: sync main into develop
StyledCheckbox sets `padding: 0` on the MUI root, so MUI's focus ripple only tints the inside of the box. On a light background that is a faint grey square, and nothing else marks keyboard focus, which falls short of WCAG 2.4.7 (Focus Visible). Draw a 2px colorBrand1 outline, offset by 2px, on `.Mui-focusVisible`, matching the color BBButton uses for its focus outline. Keying it on `.Mui-focusVisible` instead of `:focus` keeps the outline off for mouse clicks. The root's border radius follows the shape of the control (borderRadiusSmall for the square box, 50% for the round variant), so the outline traces the box instead of MUI's default circle. Restoring MUI's 9px padding was discarded: it would bring back a 39px ripple halo and change the checkbox's layout footprint for every consumer. Refs #108
…sabled The component does not pass `disabled` to its Label, which always has `cursor: pointer` and the default text color. With `disabled`, MUI dims the box, but the label still looks and points as if it were clickable. Destructure `disabled`, pass it on to the MUI checkbox and, as a transient `$disabled` prop, to the Label. A disabled label gets `cursor: not-allowed` and colorNeutral3, the same color BBButton uses for disabled text. The label is built once and placed according to `layout`, instead of being duplicated per layout. Also document `disabled` in the Storybook controls and in the README props table, and add a Disabled story. Refs #108
When BBBToggle is focused from the keyboard, MUI's focus ripple only tints the small thumb. That faint halo is the only focus cue, which falls short of WCAG 2.4.7 (Focus Visible). Draw a 2px colorBrand1 outline, offset by 2px, around the switch while it holds `.Mui-focusVisible`, the same treatment BBButton and BBBCheckbox use, so mouse clicks don't show it. The outline goes on the switch root because the track is clipped by the root's overflow. The root gets the track's border radius only while focused: a permanent radius would clip the track's anti-aliased edge a second time and slightly change how an unfocused toggle renders.
The component does not pass `disabled` to its text. With `disabled`, MUI dims the switch, but the label and helper text keep their regular colors and the text keeps `cursor: pointer`, so they look and point as if the toggle could still be changed. Destructure `disabled`, pass it on to the MUI switch and, as a transient `$disabled` prop, to the text wrapper, the label and the helper text. Disabled text gets `cursor: not-allowed` and colorNeutral3, the same color BBButton and BBBCheckbox use for disabled text. Also give the Storybook `disabled` control its default value, reword it and the README row to mention the dimmed text, and add a Disabled story.
A disabled BBBToggle in the on state looks enabled: its track stays at full brand color. The checked track's `opacity: 1` override outranks the opacity MUI applies to a disabled track, so only the unchecked track is dimmed. Restate MUI's disabled track opacity (0.12 in the light theme, 0.2 in the dark one) for a checked, disabled switch, so both states dim the same way. Add a DisabledChecked story.
BBBCheckbox has no way to show a tooltip. When a checkbox is disabled, users get no explanation of why they can't change it. BBButton and BBBAccordion already offer this through `tooltipLabel` and `tooltipPlacement`. Add the same two props, backed by Tippy like the other components. The tooltip is attached to the container around the box and the label, not to the input: MUI gives a disabled box `pointer-events: none`, so hovering it reaches the container. It opens on `mouseenter` and `focusin`, because `focusin` bubbles up from the input and Tippy's `focus` trigger does not. Tippy is rendered beside the container and pointed at it through `reference`, instead of wrapping it: wrapping would change the root element whenever `tooltipLabel` is added or removed, and React would remount the checkbox, dropping its focus and resetting an uncontrolled checkbox to `defaultChecked`. The tooltip text is also kept in a `hidden` element that the input's `aria-describedby` points to, since Tippy only mounts its content while the tooltip is shown. A visually hidden copy was discarded: it is still page text, so screen readers would read the tooltip twice in browse mode. When nothing else names the checkbox (no `label` or `ariaLabel`), the tooltip text names it through `aria-labelledby` instead of describing it, so a checkbox with only a tooltip still has an accessible name. A natively disabled input leaves the tab order, so keyboard users could never reach the tooltip that explains why it is disabled. When `disabled` and `tooltipLabel` are both set, the input gets `aria-disabled="true"` instead of the native `disabled` attribute and stays focusable: - the MUI checkbox still receives `disabled`, so the box keeps its disabled look; - an `onClick` with `preventDefault()` on the checkbox root cancels mouse clicks, label clicks and Space, and MUI skips `onChange` for a prevented click. It sits on the root because MUI drops event handlers passed through `slotProps.input`, except `onChange`; - `name` and `required` are dropped from the input, so it stays out of form submission and validation, as a natively disabled input would. Without that, a required, unchecked, aria-disabled checkbox would block its form from being submitted; - MUI never sets `Mui-focusVisible` while disabled, so the focus outline matches it through `.Mui-disabled:has(input:focus-visible)`. Without a tooltip, a disabled checkbox keeps the native `disabled` attribute and leaves the tab order, as before. Making the container focusable was discarded: focus would land on an element with no role or name, which screen readers announce poorly. Refs #108
BBBCheckbox has no way to show secondary text under its label, which BBBToggle offers through `helperText`. Consumers that need a short explanation next to a checkbox have to lay it out themselves. Add `helperText`, rendered below the label in fontSizeSmall and colorTextLight (one step below the label, as in BBBToggle), and dimmed like the label when disabled. The container turns from an inline flex row into an inline grid, with the box and the label on the first row and the helper text on the second, under the label. In a flex row, the box would be centered on the whole two-line text block instead of on the label's line. With the `left` layout, the text is aligned to the end, next to the box, so a label that wraps onto several lines is now right-aligned even without helper text. The helper text is a second <label> for the input, so clicking it toggles the checkbox, as clicking the label does; in a disabled checkbox the click does nothing. Every associated <label> joins the accessible name, which would read the helper text twice. When there is a label, the input's aria-labelledby points at the label alone and aria-describedby at the helper text, followed by the tooltip text when `tooltipLabel` is set. With no label or `ariaLabel`, the helper text names the checkbox and is left out of the description, and the tooltip text, which would otherwise name it, stays in the description. BBBToggle uses the same rule. Also document `helperText` in the Storybook controls and in the README, and add stories with the helper text on each side.
BBBToggle has no way to show a tooltip. When a toggle is disabled, users get no explanation of why they can't change it. BBButton, BBBAccordion and BBBCheckbox already offer this through `tooltipLabel` and `tooltipPlacement`. Add the same two props, backed by Tippy and wired as in BBBCheckbox. Unlike BBBCheckbox's container, the toggle's wrapper spans the whole row, so it can't trigger or anchor the tooltip: the tooltip would open over empty space and center on the row. The text and the switch root trigger it instead, and it points at the text, or at the switch when there is no text. A 100ms hide delay bridges the gap between the text and the switch, so crossing it doesn't hide and reshow the tooltip. Tippy is rendered beside the wrapper and pointed at it through `reference`, instead of wrapping it: wrapping would change the root element whenever `tooltipLabel` is added or removed, and React would remount the toggle, dropping its focus and resetting an uncontrolled toggle to `defaultChecked`. The switch root is looked up through MUI's `switchClasses.root`: the Switch ref points at its inner button, which a disabled switch hides from the pointer with `pointer-events: none`. Passing a ref through `slotProps.root` was discarded, as it could override a consumer's own root slot props. The tooltip opens on `mouseenter` and `focusin`, because `focusin` bubbles up from the input and Tippy's `focus` trigger does not. The tooltip text is also kept in a `hidden` element that the input's `aria-describedby` points to, after the helper text or `ariaDescribedBy`, since Tippy only mounts its content while the tooltip is shown. A visually hidden copy was discarded: it is still page text, so screen readers would read the tooltip twice in browse mode. When nothing else names the toggle (no `label`, `ariaLabel`, `ariaLabelledBy` or `helperText`), the tooltip text names it through `aria-labelledby` instead of describing it, so a toggle with only a tooltip still has an accessible name. A natively disabled input leaves the tab order, so keyboard users could never reach the tooltip that explains why it is disabled. When `disabled` and `tooltipLabel` are both set, the input gets `aria-disabled="true"` instead of the native `disabled` attribute and stays focusable: - the MUI switch still receives `disabled`, so it keeps its disabled look; - an `onClick` with `preventDefault()` on the switch cancels mouse clicks, label clicks and Space, and MUI skips `onChange` for a prevented click. It sits on the switch because MUI drops event handlers passed through `slotProps.input`, except `onChange`; - `name` and `required` are dropped from the input, so it stays out of form submission and validation, as a natively disabled input would; - MUI never sets `Mui-focusVisible` while disabled, so the focus outline also matches `.Mui-disabled input:focus-visible`. Without a tooltip, a disabled toggle keeps the native `disabled` attribute and leaves the tab order, as before.
fix(BBBCheckbox): show keyboard focus and disabled state; add tooltip and helper text
fix(BBBToggle): show keyboard focus and disabled state; add tooltip
The color rule, `&.Mui-checked`, is exactly as specific as MUI's own checked/indeterminate rule, so whichever stylesheet comes later wins. In BigBlueButton, MUI's emotion styles are injected after the styled-components sheet, so a checked box shows MUI's default blue (#1976d2) instead of colorBrand1. The indeterminate state was never styled, so it always showed MUI's blue. Double the class so the brand color wins in either order, and apply it to the indeterminate state too. A disabled box now always shows MUI's disabled color; where the library's rule used to win, a disabled checked box was brand-colored.
A BBButton tooltip shown on hover or keyboard focus can only be closed by moving the pointer away or moving focus elsewhere. It can cover nearby content, and WCAG 1.4.13 (Content on Hover or Focus) requires such content to be dismissible without moving the pointer or focus. Add a shared Tippy plugin, `hideOnEsc`, that hides the tooltip when Escape is pressed, and pass it to the button's Tippy. The `keydown` listener is added to the document only while the tooltip is shown and removed when it hides or is destroyed. The tooltip shows again on the next hover or focus. The plugin lives in `src/utils/tooltip.ts` so every component with a Tippy tooltip can use it. The listener runs in the capture phase, so the tooltip also hides when an Escape is stopped before it reaches the document, as react-modal does for BBBModal with `shouldCloseOnEsc`, or by a focused input that handles it. The event itself is not stopped: stopping it would hide it from the consumer's own handlers while a tooltip is shown.
The header tooltip of BBBAccordion can only be closed by moving the pointer away or moving focus elsewhere, which falls short of WCAG 1.4.13 (Content on Hover or Focus). Pass the shared `hideOnEsc` plugin to its Tippy, as BBButton does, so Escape hides the tooltip.
The name tooltip of BBBAvatar can only be closed by moving the pointer away, which falls short of WCAG 1.4.13 (Content on Hover or Focus). Pass the shared `hideOnEsc` plugin to its Tippy, as BBButton does, so Escape hides the tooltip.
The tooltip of BBBCheckbox can only be closed by moving the pointer away or moving focus elsewhere, which falls short of WCAG 1.4.13 (Content on Hover or Focus). Pass the shared `hideOnEsc` plugin to its Tippy, as BBButton does, so Escape hides the tooltip.
The tooltip of BBBToggle can only be closed by moving the pointer away or moving focus elsewhere, which falls short of WCAG 1.4.13 (Content on Hover or Focus). Pass the shared `hideOnEsc` plugin to its Tippy, as BBButton does, so Escape hides the tooltip.
The value label of BBBSlider, shown on hover, focus or drag when
`valueLabelDisplay` is 'auto', can only be closed by moving the
pointer away or moving focus elsewhere, which falls short of WCAG
1.4.13 (Content on Hover or Focus).
MUI's Slider renders the label and keeps its open state internal,
with no Escape handling, so the shared `hideOnEsc` Tippy plugin
cannot be used. Render the label through a `valueLabel` slot that
closes it on Escape and opens it again on the next hover or focus.
As in `hideOnEsc`, the listener is added to the document in the
capture phase only while the label is open, and the event is not
stopped. A label shown at all times ('on') is not hover content and
stays. A consumer's own `slots.valueLabel` still takes precedence.
fix: close tooltips with Escape
BBButton's default layout always keeps its label on one line (`white-space: nowrap`). When the button can't grow, for example a `fullWidth` button in a narrow popover or a row of equal-width buttons, a long label overflows the button or pushes the row wider. Consumers work around it by reaching into BBButton's markup: `white-space: normal` overrides to let the label wrap, or rules on the internal label <span> to truncate it with an ellipsis, which is not part of the public API. Add a `labelOverflow` prop to the default layout, setting what happens when the label doesn't fit the button's available width: - `nowrap` (default) keeps today's behavior, so no existing button changes. - `wrap` sets `white-space: normal` and `overflow-wrap: anywhere`, so the label breaks onto more lines and a single word too long for the button breaks instead of overflowing. `break-word` is not enough: it doesn't lower the button's min-content width, so a long word still widens the button past its container. - `ellipsis` gives the button `min-width: 0` and `max-width: 100%`, so it can shrink as a flex item and stay within its container, and truncates the label with an ellipsis. Truncation hides part of the label from sighted users, and most such buttons have no `tooltipLabel`. While the label is actually truncated, detected with a ResizeObserver comparing scrollWidth and clientWidth, and no `tooltipLabel` is set, the full label shows as a tooltip on hover and focus. A single Tippy is kept mounted and toggled through `disabled`, so the button is not remounted (losing focus) when the truncation state changes. That tooltip sets `aria.content` to null, because the label is already the accessible name via aria-labelledby and would otherwise be announced again as a description. `aria` is passed on every render, since Tippy keeps the previous value when the prop is omitted. Separate `wrapLabel` and `truncateLabel` booleans were considered and discarded: they can be combined into a contradictory state, and a name describing the action doesn't say it only applies when the label doesn't fit. Wrapping by default was also considered; it would make buttons that overflow today taller, so it is left out of this change.
The first story in a file is the one Storybook shows in the Docs page's top preview and binds to its Controls table. For BBButton that story is Primary, which renders three buttons with fixed labels, one per color. The preview shows three buttons instead of one, and the fixed labels override the `label` control, so editing it has no visible effect. Add a Default story, rendering a single button from the story args, as the first export. Every other component in the library already starts with a Default story. Primary and the other variant stories keep their fixed labels, since they exist to compare colors and sizes side by side.
feat(BBButton): add labelOverflow prop
fix(BBBCheckbox): show the brand color when checked or indeterminate
The subtle neutral button reuses the primary neutral colors: an opaque white background (colorWhite) with --color-gray text, while subtle default sits on a transparent background. BigBlueButton 4.1's native dark theme sets both --color-gray and --color-white to #FFFFFF, since --color-white is its text color there, so the button renders white on white. In the light theme it shows as a white pill on any surface that isn't white. Give subtle neutral the transparent background, light-gray hover and icon-default outline of subtle default, keeping only its --color-gray text. The hover then follows --color-light-gray, which the 4.1 dark theme already sets to a dark surface.
fix(BBButton): make the subtle neutral button transparent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
No breaking changes. New props make this a minor release (0.10.0 → 0.11.0).
Features
labelOverflowprop (nowrapby default,wrap,ellipsis) sets what happens when the label doesn't fit;ellipsisshows the full label as a tooltip.helperText,tooltipLabelandtooltipPlacementprops; a disabled checkbox with a tooltip stays keyboard-focusable so the tooltip can be reached.tooltipLabelandtooltipPlacementprops, with the same focusable-while-disabled behavior.Fixes
variant="subtle"withcolor="neutral"now has a transparent background, so it no longer renders white on white in the BigBlueButton 4.1 dark theme.