Closed samreid closed 1 year ago
Good news, everyone! Panels already disappear if you remove their elements. You can demonstrate this in CCK by tapping on a battery, then making the reverse battery button, slider and trash button invisible. The panel automatically disappears.
So why doesn't this work for the DisplayOptionsPanel in the top right? Because its width is managed by an AlignBox. Removing the AlignBox breaks the alignment (now it doesn't match size with lower panel), but now when you remove the radio buttons and checkboxes, the panel disappears:
Is there a way to match their widths while still preserving the "disappear when all content is gone" idea? Perhaps @jonathanolson or @marlitas would know best?
I added a sim-specific workaround which has the desired behavior. I'm not a fan of the complexity, or of having to do this for other panels (in CCK or elsewhere). Hopefully there is a better way? @matthew-blackman or @jonathanolson or @marlitas what do you think?
Why using AlignBox? If it's to have the panels be the same with, just use stretch: true
on the VBox?
Good idea, thanks! I will try it.
I started going down the https://github.com/phetsims/circuit-construction-kit-common/issues/939#issuecomment-1414486082 path with this patch, but quickly remembered conversations about VBox not having a good way to stretch to it's parent container (@jonathanolson please correct me if I'm wrong).
@samreid and I talked through this patch a bit and also came across accordion box still now being a resizable component. https://github.com/phetsims/sun/issues/803 That may be affecting how accordion box is reacting in this patch as well as in https://github.com/phetsims/circuit-construction-kit-common/issues/940.
It seems some designer input might be needed on best way to move forward in terms of effort and priorities.
I believe VBox naturally can stretch to the size of a parent container (based on preferred width).
Instead of shrinking the AccordionBox width, can we use it as the preferred with of the panel? Basically, let the panel expand to match instead of trying to shrink down the AccordionBox. From @jonathanolson's comment above, that sounds like a possibility.
In the patch, the accordion box is thinner than the above panels, so it looks like this (ignore the fact it is over the carousel):
So we would have to make the accordion box >= the width of the other panels for that strategy to work. AccordionBox does not yet dynamically reshape.
I'm feeling this issue could be turned into a flex "if time" goal and removed from the milestone. Some panels automatically disappear when the last component is removed. Others do not. For this version, clients can just hide the whole panel if needed. We can keep this feature in mind for future phet-io sims when there aren't other layout considerations.
@arouinfar ok to remove from milestone?
I'm feeling this issue could be turned into a flex "if time" goal and removed from the milestone. Some panels automatically disappear when the last component is removed. Others do not. For this version, clients can just hide the whole panel if needed. We can keep this feature in mind for future phet-io sims when there aren't other layout considerations.
@arouinfar ok to remove from milestone?
Let's remove it from the milestone. Using a panel's visibleProperty
will always be the easiest way to completely hide it. I do not think automatically hiding the panel is a necessary feature.
I feel we could go one step further and just close this issue? It doesn't seem important to implement or have on a back-up list in my opinion. @arouinfar sound OK?
Let's close!
Address https://github.com/phetsims/sun/issues/824