Skip to content

Commit

Permalink
support Dialogs opting out of state when they are encapsulated (Pheti…
Browse files Browse the repository at this point in the history
…oCapsule), phetsims/phet-io#1559
  • Loading branch information
zepumph committed Oct 23, 2019
1 parent 9932251 commit 9fef7e8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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',
Expand All @@ -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' );
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 9fef7e8

Please sign in to comment.