-
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
Convert ComboBoxItem from class
to type
#768
Comments
class ComboBoxItem
with type ComboBoxItem
.class
to type
Devs at today's meeting agree! Notes in the dev meeting doc. |
Notes from dev meeting doc:
|
I understand needing to serialize an ComboBoxItem's That said... If ComboBoxItem does need to be serialized, then is the same true for AquaRadioButtonGroupItem, RectangularRadioButtonItem, VerticalCheckboxGroupItem, ComboBoxDisplayItem, etc? And should they be converted from So I see 2 options: |
The only assertion that isn't replaced by TypeScript type-checking is this one: assert && assert( !node.hasPDOMContent, 'pdomContent is set by ComboBox, use options.a11yLabel' ); @jessegreenberg Do other item types (eg AquaRadioButtonGroupItem) need this same assertion? Why or why not?
We definintely don't want to rely on this assertion having to be copied to multiple places for the same type of item. So if the Adding @jessegreenberg to the discussion, please weigh in with your recommendation -- option (1) or (2)? |
We do not want to do this at this time, nor do I think that we will ever want to. The dev meeting conversation was more general about class vs types and why we may not want to convert/use a type over a class. This shouldn't block converting ComboBoxItem in my opinion. |
Does it have to be in multiple spots? Can we just check it once at the top of the constructor of ComboBox? |
I think that's probably the case - one check in ComboBox. And it would certainly be preferrable to confirm
|
This assertion currently appears in ComboBoxItem: assert && assert( !node.hasPDOMContent, 'pdomContent is set by ComboBox, use options.a11yLabel' ); While investigating relocating this responsibility to ComboBox, I discovered that ComboBox does not set @jessegreenberg what am I missing here? Is the ComboBoxItem assertion vestigial? Is something missing in ComboBox? |
Hmmm... This makes converting ComboBoxItem to a class ChallengeComboBoxItem extends ComboBoxItem<number> ... and ChallengeComboBoxItem does some work that a ChallengeComboBoxItem is a bad design. The responsibility for setting the background color of the sim should not be in the item. The item should select a value, and setting the background color based on the value should be handled elsewhere. @zepumph may I change this? What I said about ChallengeComboBoxItem is true in general. Items should not have responsibilities like this. |
Yes that makes sense. Go ahead and make that change. Thanks! |
That comment was stated generally as a potential worry, but ComboBoxItem only has one usage.
There is no |
@jessegreenberg and I just discussed this a bit more, and we feel totally fine about using types instead of classes. We do like that assertion though, and wished that it was in other item-like spots, for example over in sun/js/buttons/RectangularRadioButtonGroup.ts Lines 264 to 265 in d2e9d3c
We think we should add that check where other a11y items objects are turned into the item classes that the view components use. |
@zepumph @jessegreenberg thanks for the feedback. I'm going to address ChallengeComboBoxItem first in phetsims/ratio-and-proportion#484. That is a pre-requisite to converting ComboBoxItem to a |
Summary of the above commits:
To Slack#dev-plublic:
@jbphet randomly selected to review. |
Changes look good to me. I also thought through the whole serialization thing (I think I'm the one who raised the question in the meeting), and I agree that we're very unlikely to ever need to serialize individual combo box items. I also did a bit of regression testing on Molarity and States of Matter, since they both use I found an unrelated problem with the sound while doing this review and created a separate issue for it (see link above). I'll follow up on that separately. Closing. |
I'd like to replace
class ComboBoxItem
withtype ComboBoxItem
:A
type
would be more consistent with the pattern used for RectangularRadioButtonItem and AquaRadioButtonGroupItem. And I think that usage sites would read better.Before proceeding, I'll bring this up at developer meeting to see if there are preferences/objections.
The text was updated successfully, but these errors were encountered: