Skip to content

Commit

Permalink
Find a default accessibleName for ComboBox items, see #911 and phetsi…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Nov 8, 2024
1 parent fabd4c4 commit f5fb7de
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/ComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.
import optionize from '../../phet-core/js/optionize.js';
import IntentionalAny from '../../phet-core/js/types/IntentionalAny.js';
import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import { Display, extendsWidthSizable, Focus, FocusManager, isWidthSizable, MatrixBetweenProperty, Node, NodeOptions, PDOMBehaviorFunction, PDOMPeer, PDOMValueType, TColor, TInputListener, TPaint, TrimParallelDOMOptions, WidthSizable, WidthSizableOptions } from '../../scenery/js/imports.js';
import { Display, extendsWidthSizable, Focus, FocusManager, isWidthSizable, MatrixBetweenProperty, Node, NodeOptions, PDOMBehaviorFunction, PDOMPeer, PDOMUtils, PDOMValueType, TColor, TInputListener, TPaint, TrimParallelDOMOptions, WidthSizable, WidthSizableOptions } from '../../scenery/js/imports.js';
import sharedSoundPlayers from '../../tambo/js/sharedSoundPlayers.js';
import TSoundPlayer from '../../tambo/js/TSoundPlayer.js';
import EventType from '../../tandem/js/EventType.js';
Expand Down Expand Up @@ -252,6 +252,14 @@ export default class ComboBox<T> extends WidthSizable( Node ) {

const nodes = getGroupItemNodes( items, options.tandem.createTandem( 'items' ) );

// pdom - If an item has not been given an accessibleName, try to find a default value from the visual Node.
// Assigned to the item, because the accessible name is used in the ComboBoxButton and ComboBoxListItemNode.
items.forEach( ( ( item, i ) => {
if ( !item.accessibleName ) {
item.accessibleName = PDOMUtils.findStringProperty( nodes[ i ] );
}
} ) );

assert && nodes.forEach( node => {
assert && assert( !node.hasPDOMContent, 'Accessibility is provided by ComboBoxItemNode and ' +
'ComboBoxItem.accessibleName. Additional PDOM content in the provided ' +
Expand Down

0 comments on commit f5fb7de

Please sign in to comment.