Repository navigation
Conversation
BBButton has no selected state, so a toggle button, or a group where one option is picked, has to be painted by the consumer. The poll panel's response-type picker switches variants and repaints both states with eight !important declarations, because the library's hover rule outranks any ordinary override, and screen readers hear plain buttons with no selection. Add a `pressed` prop. When it is set, the button renders `aria-pressed`; when it is true, the button gets a fill that holds through hover and active. The fill depends on `color` only, so a pressed button reads as selected next to any variant, and the colors live in a table in constants.ts for the design team to refine. A pressed button that is also disabled fades its fill instead of turning grey, so a disabled group still shows which option is selected. Forwarding `aria-pressed` alone was considered: it fixes the accessibility gap but leaves the style overrides in place. Closes bigbluebutton#107
Side panels in the BigBlueButton client lay out their footer buttons by hand: two buttons side by side that stack once the panel gets too narrow, under a divider. Each panel redeclares its own divider, gaps and wrapping rules. Add BBBButtonGroup, which lays its children out in one row of equal-width buttons and stacks them at full width according to `stack`: never, always, once the group is narrower than `stackBelow`, or once the widest button no longer fits its share of the row, measured with a ResizeObserver. `footer` renders a BBBDivider above the buttons and makes the width rule the default. Where the group sits in the panel stays up to the panel. The width rule uses flex-basis arithmetic instead of a container query, because styled-components 5, which the client uses, drops the selector of a nested @container rule. A plain wrapping flex-basis was discarded because with three or more buttons it splits them across uneven rows; the group stacks all or nothing.
Groups where exactly one option is picked are built by hand in the BigBlueButton client: the timer panel's Timer/Stopwatch switch, the poll response types and the poll/quiz selector. The timer disables the selected button so it cannot be clicked again, which screen readers announce as unavailable rather than selected. Add BBBSegmentedControl, a controlled group that renders each option as a BBButton and marks the selected one with `pressed`, under role="group". Clicking the selected option does not call `onChange`, so consumers no longer need to disable it, and disabling the whole group keeps the selected option visible. The options are laid out by BBBButtonGroup, and `stack` and `stackBelow` are passed through to it. Radiogroup semantics with arrow-key navigation were discarded for now: they need BBButton to forward refs and accept role, aria-checked and tabIndex. The group can switch to them later without changing its API. Tabs are left out because these groups pick a value rather than switch between views.
Comment on lines
+55
to
+58
| const observer = new ResizeObserver(check); | ||
| observer.observe(buttons); | ||
| return () => observer.disconnect(); | ||
| }, [stack, children]); |
Contributor
There was a problem hiding this comment.
children is new on every parent render, so with stack="overflow" this forces a layout and creates a new ResizeObserver each time (20 renders, 20 observers). Depending on [stack] and catching label changes with a MutationObserver keeps the behaviour:
Suggested change
| const observer = new ResizeObserver(check); | |
| observer.observe(buttons); | |
| return () => observer.disconnect(); | |
| }, [stack, children]); | |
| const resizeObserver = new ResizeObserver(check); | |
| resizeObserver.observe(buttons); | |
| const mutationObserver = new MutationObserver(check); | |
| mutationObserver.observe(buttons, { subtree: true, childList: true, characterData: true }); | |
| return () => { | |
| resizeObserver.disconnect(); | |
| mutationObserver.disconnect(); | |
| }; | |
| }, [stack]); |
This branch has not been deployed
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?
Adds a pressed (selected) state to
BBButton, plus two components built on it: a layout group for side panel buttons and a single-choice option group.BBButtonpressedprop:true/falserendersaria-pressed;trueapplies a selected fill percolorthat holds through hover and press. A disabled pressed button fades its fill instead of turning grey, so the current choice stays visible.New



BBBButtonGroup: lays buttons out in one row of equal-width buttons and stacks them at full width according tostack:never(default),always,width(belowstackBelow, default20.75rem) oroverflow(once the widest label no longer fits its share of the row).BBBButtonGroupfooterprop: renders a divider above the buttons for side panel footers and makesstack="width"the default.New
BBBSegmentedControl: a controlled group where exactly one option is selected, rendered as pressed buttons underrole="group"; clicking the selected option does not callonChange. Acceptsstack/stackBelow, passed toBBBButtonGroup.READMEs, Storybook stories and demo images for all three; both components are exported per entry point (
/ButtonGroup,/SegmentedControl).Closes Issue(s)
Closes #107
Motivation
Toggle buttons, single-choice groups and the two-buttons-then-stack panel footer are rebuilt by hand in each BigBlueButton client panel, with style overrides for the selected state and no selection announced to screen readers.
More
npm run storybook.