From 9fef7e8d04ae3a071cfdd8139dd1371174a40e4d Mon Sep 17 00:00:00 2001 From: zepumph Date: Wed, 23 Oct 2019 14:43:12 -0800 Subject: [PATCH] support Dialogs opting out of state when they are encapsulated (PhetioCapsule), https://github.com/phetsims/phet-io/issues/1559 --- js/Dialog.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/Dialog.js b/js/Dialog.js index 6280a960..b98006b9 100644 --- a/js/Dialog.js +++ b/js/Dialog.js @@ -25,6 +25,7 @@ define( require => { const merge = require( 'PHET_CORE/merge' ); const Panel = require( 'SUN/Panel' ); const Path = require( 'SCENERY/nodes/Path' ); + const PhetioObject = require( 'TANDEM/PhetioObject' ); const Property = require( 'AXON/Property' ); const RectangularButtonView = require( 'SUN/buttons/RectangularButtonView' ); const RectangularPushButton = require( 'SUN/buttons/RectangularPushButton' ); @@ -131,6 +132,7 @@ define( require => { phetioType: DialogIO, phetioReadOnly: false, // default to false so it can pass it through to the close button phetioState: false, // default to false so it can pass it through to the close button + phetioComponentOptions: null, // filled in below with PhetioObject.mergePhetioComponentOptions() // a11y options tagName: 'div', @@ -150,6 +152,11 @@ define( require => { options.tandem = Tandem.optional; } + // by default, copy the state of the dialog + PhetioObject.mergePhetioComponentOptions( { + phetioState: options.phetioState + }, options ); + assert && assert( options.xMargin === undefined, 'Dialog sets xMargin' ); options.xMargin = 0; assert && assert( options.yMargin === undefined, 'Dialog sets yMargin' ); @@ -201,7 +208,8 @@ define( require => { // phet-io tandem: options.tandem.createTandem( 'closeButton' ), phetioReadOnly: options.phetioReadOnly, // match the readOnly of the Dialog - phetioState: options.phetioState, // match the state transfer of the Dialog + phetioState: false, // close button should not be in state + phetioComponentOptions: { phetioState: false }, // a11y tagName: 'button',