phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

AccordionBox is handling margins inconsistently #892

Open marlitas opened 1 week ago

marlitas commented 1 week ago

While working on layout for NumberPairs I noticed that the contentXMarginwasn't being applied as expected. It appeared to be splitting the margin in half since the margin was not being multiplied by 2 in the minimum width calculation when showTitleWhenExpanded is set to false.

I further noticed that titleXMargin is being multiplied by 2 in all scenarios.

Understandably contentYMargin is only being multiplied when showTitleWhenExpanded is false. I assume this is because we do not want to apply a margin between the title and the content, we only want to apply contentYSpacing.

Overall, it seems like contentXMargin is not being applied consistently or as expected. Since this affects a large number of sims I would like to discuss with @jonathanolson before moving forward.

    // content is next to button
    else {
      minimumBoxWidth = Math.max( minimumBoxWidth, this.expandCollapseButton.width + minimumContentWidth + options.buttonXMargin + options.contentXMargin + options.contentXSpacing );
    }