Skip to content

Commit

Permalink
'Item' nodes cannot have PDOM content, see #771
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Jun 28, 2022
1 parent 4631abb commit ee394ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions js/AquaRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export default class AquaRadioButtonGroup<T> extends FlowBox {
for ( let i = 0; i < items.length; i++ ) {
const item = items[ i ];

assert && assert( !item.node.hasPDOMContent,
'Accessibility is provided by AquaRadioButton and AquaRadioButtonGroupItem.labelContent. ' +
'Additional PDOM content in the provided Node could break accessibility.' );

// Content for the radio button.
// For vertical orientation, add an invisible strut, so that buttons have uniform width.
const content = ( options.orientation === 'vertical' ) ?
Expand Down
6 changes: 5 additions & 1 deletion js/buttons/RectangularRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { Shape } from '../../../kite/js/imports.js';
import InstanceRegistry from '../../../phet-core/js/documentation/InstanceRegistry.js';
import merge from '../../../phet-core/js/merge.js';
import { Color, FocusHighlightPath, IInputListener, IPaint, FlowBox, FlowBoxOptions, Node, PDOMPeer, Rectangle, SceneryConstants } from '../../../scenery/js/imports.js';
import { Color, FlowBox, FlowBoxOptions, FocusHighlightPath, IInputListener, IPaint, Node, PDOMPeer, Rectangle, SceneryConstants } from '../../../scenery/js/imports.js';
import multiSelectionSoundPlayerFactory from '../../../tambo/js/multiSelectionSoundPlayerFactory.js';
import Tandem from '../../../tandem/js/Tandem.js';
import ColorConstants from '../ColorConstants.js';
Expand Down Expand Up @@ -286,6 +286,10 @@ export default class RectangularRadioButtonGroup<T> extends FlowBox {
radioButtonGroupMemberOptions.tandem = options.tandem.createTandem( item.tandemName );
}

assert && assert( !item.node.hasPDOMContent,
'Accessibility is provided by RectangularRadioButton and RectangularRadioButtonItem.labelContent. ' +
'Additional PDOM content in the provided Node could break accessibility.' );

// create the label and voicing response for the radio button
if ( item.labelContent ) {
radioButtonGroupMemberOptions.labelContent = item.labelContent;
Expand Down

0 comments on commit ee394ab

Please sign in to comment.