From 8cd164733ca6ebe78f76d3c559c90c3a232e4a75 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Sat, 9 Jul 2022 15:59:51 -0600 Subject: [PATCH] handle ?gameLevels before calling super, https://github.com/phetsims/vegas/issues/108 --- js/LevelSelectionButtonGroup.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/LevelSelectionButtonGroup.ts b/js/LevelSelectionButtonGroup.ts index c391530..dffc11a 100644 --- a/js/LevelSelectionButtonGroup.ts +++ b/js/LevelSelectionButtonGroup.ts @@ -87,14 +87,10 @@ export default class LevelSelectionButtonGroup extends Node { const buttons: LevelSelectionButton[] = items.map( item => new LevelSelectionButton( new AlignBox( item.icon, alignBoxOptions ), item.scoreProperty, combineOptions( { - tandem: options.tandem.createTandem( item.tandemName! ) + tandem: options.tandem.supplied ? options.tandem.createTandem( item.tandemName! ) : Tandem.OPT_OUT }, item.options ) ) ); - options.children = [ options.createLayoutNode( buttons ) ]; - - super( options ); - // Hide buttons for levels that are not included in gameLevels. // All buttons must be instantiated so that the PhET-iO API is not changed conditionally. if ( options.gameLevels ) { @@ -105,6 +101,11 @@ export default class LevelSelectionButtonGroup extends Node { button.visible = options.gameLevels!.includes( index + 1 ); } ); } + + // Create the layout for the buttons. + options.children = [ options.createLayoutNode( buttons ) ]; + + super( options ); } }