phetsims / sun

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

TextPushButton with a maxWidth can result in buggy layout cases #791

Closed jonathanolson closed 1 year ago

jonathanolson commented 1 year ago

NOTE: Cases seem to be resolvable by using maxTextWidth instead (and that's preferable), but this indicates something broken in how we're doing layout.

To reproduce:

  1. In WOAS's RestartButton, replace maxTextWidth with maxWidth.
  2. Run WOAS with a long string test (e.g. &stringTest=asrtaslrtknalrstknalsrktnalsrktnalsrktnalskrntalskrntalksrntasrt)

Result:

image
jonathanolson commented 1 year ago

The button is properly sized until it is put into an HBox.

Then it gets a preferred size somehow set that is iterating the scale up (and the localPreferredWidth goes WELL below the minimumWidth). This stops once the scale is approximately back at 1 (so no INFINITE loop)

If we increase the scale (due to maxWidth not needing as much of a reduction), then it lowers the localPreferredWidth to a buggy state. We're not hard-erroring when the preferred size goes BELOW the minimum size, perhaps that's worth more of an investigation.

I'm also curious if some "stroke" size thing is going on, a factor of 1.0006832027530936 is happening for the first scale adjustment.

Also, if I set the preferredWidth of the button to 250 before putting it in the HBox, all is fine.

marlitas commented 1 year ago

I believe I remember us fixing this, and I also tried to reproduce and couldn't, so closing as completed!