Open marlitas opened 11 months ago
Dev Meeting 12/7/23
JO: Any objections to refactoring to remove these usages?
I'll be happy to address refactoring any in the sims that I'm responsible for. I see 2 so far in the list above, which I'll take care of now.
Some other common-code UI components that have "content" (not a complete list) ...
Thanks @pixelzoom! I'll keep going through components to make a comprehensive list. I will plan on refactoring the common code components that need this work done.
In case it's useful, I added this at the end of relevant constructors to identify culprits:
this.childrenChangedEmitter.addListener( () => console.log( new Error( 'children changed' ).stack ) );
So far none of these components have raised any errors:
I'll continue checking components that use the "content" pattern, especially those that extend sizable.
Tested components:
This would be good to put on the radar again. I would love some help as I don't think I have the bandwidth to complete myself. I'll add it to the dev board to discuss in the next meeting and see if I can wrangle a co-conspirator.
Recommendation from developer meeting:
I will take a look at the common code components this iteration, and also review the assertions that were proposed here.
It is possible that some of these have already been fixed.
I will take a look at the common code components this iteration, and also review the assertions that were proposed here.
It is possible that some of these have already been fixed.
From https://github.com/phetsims/sun/issues/860#issue-2031266798, the common-code components are:
- [ ] RectangularRadioButton (sun)
- [ ] LevelSelectionButton (vegas)
LevelSelectionButton is already fixed. @marlitas said the problem was fixed in https://github.com/phetsims/vegas/commit/f605de47e2d8c5ede7d12b668d637865cda80e5f. And I recently (7/31/24) added support for dynamic layout.
I don't know about RectangularRadioButton.
Here is what I have done so far -
assertNoAdditionalChildren
was added to /scenery/js/util/. You can add it to a component after content has been set up.RectangularRadioButton
and the components listed in https://github.com/phetsims/sun/issues/860#issuecomment-1856551438 are using it and sims have been changed to avoid the assertion. Side issues were assigned to responsible devs for review.While working on this, it was pointed out that some components should allow having children added to them (like Slider and RichText), because the implementation of their layout does not make assumptions about children.
However, @jonathanolson suggested that all common code components should discourage adding children to them because a) it is difficult to review the implementation of each and decide whether assumptions are made and b) adding children to UI components makes usages less maintainable.
We need to check in at developer meeting to decide next steps.
Dev meeting decision:
@jessegreenberg thoughts on what would be good to do now?
@jessegreenberg I will have some time again to finish this off. Would you like to meet and discuss next steps?
Components that handle the layout of their children such as: ButtonNode, AccordionBox, Panel, Carousel, etc should not use the decorator pattern. Adding children to these components outside of the "content" or "contentNode" seems like an anti-pattern. We would like to discourage these Node subclasses from adding children through options or mutation.
Affected ButtonNode Subclasses:
Affected AccordionBox Subclasses:
Affected Panel Subclasses/Usages: