From 91e89560e27caa555fac8cc0897bbecdb5d8b1ea Mon Sep 17 00:00:00 2001 From: zepumph Date: Tue, 29 Oct 2019 10:09:58 -0800 Subject: [PATCH] rename playAreaNode -> pdomPlayAreaNode, override setChildren to keep PDOM Nodes, https://github.com/phetsims/scenery-phet/issues/381 --- js/ScreenView.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/js/ScreenView.js b/js/ScreenView.js index 426fad35..f7fcbbbd 100644 --- a/js/ScreenView.js +++ b/js/ScreenView.js @@ -81,7 +81,6 @@ define( require => { // a11y - this Node is suffixed "container" because it is added to with sim specific screen summary content, often // called {Sim}ScreenSummaryNode. This container has the intro "{sim} is an interactive sim, it changes as you . . ." this._screenSummaryNode = new ScreenSummaryNode(); - this.addChild( this._screenSummaryNode ); // @private {Node|null} - keep track of the content added to the summary Node, so that if it is set more than once, // the previous one can be removed. @@ -91,16 +90,37 @@ define( require => { options.screenSummaryContent && this.setScreenSummaryContent( options.screenSummaryContent ); // @public (read-only) - add children and set accessible order to these to organize and structure the PDOM. - this.playAreaNode = new PlayAreaNode(); - this.addChild( this.playAreaNode ); + this.pdomPlayAreaNode = new PlayAreaNode(); this.controlAreaNode = new ControlAreaNode(); - this.addChild( this.controlAreaNode ); + + // @private + this.pdomParent = new Node( { + children: [ + this._screenSummaryNode, + this.pdomPlayAreaNode, + this.controlAreaNode + ] + } ); + this.addChild( this.pdomParent ); } joist.register( 'ScreenView', ScreenView ); return inherit( Node, ScreenView, { + /** + * Override to make sure that setting children doesn't blow away Nodes set by ScreenView. + * @override + * @param {Node[]} children + */ + setChildren( children ) { + Node.prototype.setChildren.call( this, children ); + if ( !this.hasChild( this.pdomParent ) ) { + this.addChild( this.pdomParent ); + this.pdomParent.moveToBack(); + } + }, + /** * Get the scale to use for laying out the sim components and the navigation bar, so its size will track * with the sim size