-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components with "content" should refrain from Decorator Pattern #860
Comments
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. |
From #860 (comment), the common-code components are:
LevelSelectionButton is already fixed. @marlitas said the problem was fixed in phetsims/vegas@f605de4. 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 -
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? |
This seems like good improvement that we can loop into #922 and phet-io common code work. |
I did the recommendation for ComboBox, and local testing looks good. I'll check on CT in a bit. Unassigning. |
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:
The text was updated successfully, but these errors were encountered: