Skip to content

Commit

Permalink
Update focus order for the explore screen, see #121
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed May 8, 2024
1 parent 6d8b988 commit d4aa9af
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
29 changes: 29 additions & 0 deletions js/buoyancy/view/BuoyancyExploreScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import ThreeUtils from '../../../../mobius/js/ThreeUtils.js';
import DensityBuoyancyCommonColors from '../../common/view/DensityBuoyancyCommonColors.js';
import ForceDiagramNode from '../../common/view/ForceDiagramNode.js';
import buoyancy_explore_screen_block_png from '../../../images/buoyancy_explore_screen_block_png.js';
import CuboidView from '../../common/view/CuboidView.js';
import ScaleView from '../../common/view/ScaleView.js';

// constants
const MARGIN = DensityBuoyancyCommonConstants.MARGIN;
Expand Down Expand Up @@ -181,6 +183,33 @@ export default class BuoyancyExploreScreenView extends DensityBuoyancyScreenView
} );

this.addChild( this.popupLayer );

const cuboidViews = this.massViews.filter( massView => massView instanceof CuboidView );
const scaleViews = this.massViews.filter( massView => massView instanceof ScaleView );

// The focus order is described in https://github.com/phetsims/density-buoyancy-common/issues/121
this.pdomPlayAreaNode.pdomOrder = [

cuboidViews[ 0 ].focusablePath,
this.rightBox.primaryControlNode,

// TODO: Add cuboidViews[1] which is created lazily when the radio button is pressed, see https://github.com/phetsims/density-buoyancy-common/issues/121
// cuboidViews[ 1 ].focusablePath,
this.rightBox.secondaryControlNode,

fluidDensityControlPanel,

// The blocks are added (a) pool then (b) outside, but the focus order is (a) outside then (b) pool
..._.reverse( scaleViews.map( scaleView => scaleView.focusablePath ) )
];

this.pdomControlAreaNode.pdomOrder = [
blocksRadioButtonGroup,
buoyancyDisplayOptionsNode,
densityAccordionBox,
submergedAccordionBox,
this.resetAllButton
];
}

public static getBuoyancyExploreIcon(): Node {
Expand Down
1 change: 1 addition & 0 deletions js/buoyancy/view/BuoyancyIntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default class BuoyancyIntroScreenView extends DensityBuoyancyScreenView<B
const cuboidViews = this.massViews.filter( massView => massView instanceof CuboidView );
const scaleViews = this.massViews.filter( massView => massView instanceof ScaleView );

// The focus order is described in https://github.com/phetsims/density-buoyancy-common/issues/121
this.pdomPlayAreaNode.pdomOrder = [

// TODO: When the cuboids change from the radio buttons, this needs to update. So consider a different parent for this part
Expand Down
8 changes: 8 additions & 0 deletions js/common/view/PrimarySecondaryControlsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export type PrimarySecondaryControlsNodeOptions = SelfOptions & BlockControlNode

export default class PrimarySecondaryControlsNode extends PrimarySecondaryPanelsNode {

// Controls for the primary and secondary masses. Public so they can be split up in the focus order,
// see https://github.com/phetsims/density-buoyancy-common/issues/121
public readonly primaryControlNode: BlockControlNode;
public readonly secondaryControlNode: BlockControlNode;

/**
* @param primaryMass
* @param secondaryMass
Expand Down Expand Up @@ -58,6 +63,9 @@ export default class PrimarySecondaryControlsNode extends PrimarySecondaryPanels
visibleProperty: DerivedProperty.and( [ secondaryMass.visibleProperty, secondaryControlNode.visibleProperty ] )
} )
);

this.primaryControlNode = primaryControlNode;
this.secondaryControlNode = secondaryControlNode;
}
}

Expand Down

0 comments on commit d4aa9af

Please sign in to comment.