From c7d4466a45eb50bf3fb9c845fa09e9c8844f4664 Mon Sep 17 00:00:00 2001 From: chrisklus Date: Wed, 14 Nov 2018 11:26:48 -0700 Subject: [PATCH] Factored out component property link and added to ComboBox, see https://github.com/phetsims/sun/issues/405 --- js/Checkbox.js | 12 +----------- js/ComboBox.js | 4 +++- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/js/Checkbox.js b/js/Checkbox.js index 35fdb952..bd340d87 100644 --- a/js/Checkbox.js +++ b/js/Checkbox.js @@ -49,6 +49,7 @@ define( function( require ) { phetioEventType: 'user', phetioReadOnly: PhetioObject.DEFAULT_OPTIONS.phetioReadOnly, // to support properly passing this to children, see https://github.com/phetsims/tandem/issues/60 phetioDocumentation: '', // different default than PhetioObject, see implementation below + phetioControlledProperty: property, // a11y tagName: 'input', @@ -90,13 +91,6 @@ define( function( require ) { phetioDocumentation: 'When disabled, the checkbox is grayed out and cannot be pressed.' } ); - // (phet-io) document the instrumented Property that this Checkbox manipulates - options.phetioDocumentation += - ' This checkbox controls the PropertyIO.<BooleanIO>: ' + - '' + property.tandem.phetioID + ''; - options.phetioDocumentation = options.phetioDocumentation.trim(); // eliminate preceding whitespace, if any. - - // @private - sends out notifications when the checkbox is toggled. var toggledEmitter = new Emitter( { tandem: options.tandem.createTandem( 'toggledEmitter' ), @@ -181,10 +175,6 @@ define( function( require ) { // assert that phet-io is set up correctly after the PhetioObject has been properly initialized (after mutate) - // If either one is instrumented, then the other must be too. - assert && Tandem.validationEnabled() && assert( this.isPhetioInstrumented() === property.isPhetioInstrumented(), - 'Property must be instrumented if controlling Checkbox is.' ); - // If either one is instrumented, then the other must be too. assert && Tandem.validationEnabled() && assert( this.enabledProperty.isPhetioInstrumented() === this.isPhetioInstrumented(), 'provided enabled property must be instrumented for phet-io.' ); diff --git a/js/ComboBox.js b/js/ComboBox.js index 24697dac..8bd8ea7b 100644 --- a/js/ComboBox.js +++ b/js/ComboBox.js @@ -74,6 +74,8 @@ define( require => { tandem: Tandem.required, phetioType: ComboBoxIO, phetioEventType: 'user', + phetioDocumentation: '', // different default than PhetioObject, see implementation below + phetioControlledProperty: property, // a11y a11yButtonLabel: '' // {string} accessible label for the button that opens this combobox @@ -273,7 +275,7 @@ define( require => { this.buttonNode = new ButtonNode( new ComboBoxItemNode( items[ 0 ], itemWidth, itemHeight, options.itemXMargin ), options ); this.addChild( this.buttonNode ); - // a11y - the list is labelledby the button's label + // a11y - the list is labeled by the button's label this.listNode.addAriaLabelledbyAssociation( { otherNode: this.buttonNode, otherElementName: AccessiblePeer.LABEL_SIBLING,