From ee394ab10393cec3dcc4f1ad532101bdb237f26b Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 28 Jun 2022 15:53:38 -0400 Subject: [PATCH] 'Item' nodes cannot have PDOM content, see https://github.com/phetsims/sun/issues/771 --- js/AquaRadioButtonGroup.ts | 4 ++++ js/buttons/RectangularRadioButtonGroup.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js/AquaRadioButtonGroup.ts b/js/AquaRadioButtonGroup.ts index cd27d23e..36df9606 100644 --- a/js/AquaRadioButtonGroup.ts +++ b/js/AquaRadioButtonGroup.ts @@ -97,6 +97,10 @@ export default class AquaRadioButtonGroup 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' ) ? diff --git a/js/buttons/RectangularRadioButtonGroup.ts b/js/buttons/RectangularRadioButtonGroup.ts index a8f5da32..78d460e5 100644 --- a/js/buttons/RectangularRadioButtonGroup.ts +++ b/js/buttons/RectangularRadioButtonGroup.ts @@ -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'; @@ -286,6 +286,10 @@ export default class RectangularRadioButtonGroup 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;