Skip to content
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

AquaRadioButton and RadioButtonGroup are instrumented differently #550

Closed
pixelzoom opened this issue Dec 18, 2019 · 10 comments
Closed

AquaRadioButton and RadioButtonGroup are instrumented differently #550

pixelzoom opened this issue Dec 18, 2019 · 10 comments

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 18, 2019

Noted while working on #549, and Natural Selection, which has both types of radio buttons.

AquaRadioButton and the buttons created by RadioButtonGroup are instrumented differently. This is another impediment to unifying the implementations of radio buttons and their groups, see #523.

The differences are:

(1) AquaRadioButton input listener has tandem name 'inputListener', RadioButtonGroup is 'pressListener'.
(2) RadioButtonGroup has 'firedEmitter', which is absent from AquaRadioButton.
(3) RadioButtonGroup lacks '*property', the link to its associated Property, which is being addressed in #549.

AquaRadioButton example from NATURAL_SELECTION/GraphsRadioButtonGroup:

screenshot_30

RadioButtonGroup button example from NATURAL_SELECTION/EnvironmentRadioButtonGroup:

screenshot_31

chrisklus added a commit to phetsims/balloons-and-static-electricity that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/energy-skate-park-basics that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/capacitor-lab-basics that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/resistance-in-a-wire that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/gravity-and-orbits that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/gravity-force-lab that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/energy-skate-park that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/natural-selection that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/projectile-motion that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/gas-properties that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/concentration that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/build-an-atom that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/beers-law-lab that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/coulombs-law that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/hookes-law that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/diffusion that referenced this issue Jan 3, 2020
chrisklus added a commit to phetsims/ohms-law that referenced this issue Jan 3, 2020
@chrisklus
Copy link
Contributor

Discussed with @samreid, @zepumph, and @jonathanolson.

For (1), we renamed inputListener to fireListener in AquaRadioButton.js.

Regarding (2), a firedEmitter exists for AquaRadioButton, it's just nested under its fireListener.

@pixelzoom
Copy link
Contributor Author

I'm trying to figure out what was actually accomplished here. It looks like all you did is rename the differences so that the APIs are still different. The example I used above is now:

AquaRadioButton example from NATURAL_SELECTION/GraphsRadioButtonGroup:

screenshot_40

RadioButtonGroup button example from NATURAL_SELECTION/EnvironmentRadioButtonGroup:

screenshot_39

@zepumph
Copy link
Member

zepumph commented Jan 3, 2020

AquaRadioButton and RadioButtonGroup use completely different guts. In an effort to try to align them without completely refactoring them, we decided that this rename was an improvement.

The two items we were trying to solve were (1) and (2) from #550 (comment) since (3) will be covered in the other issue.

Since RadioButtonGroupMember is a sun button, it uses a PressListener, and is not able to use a FireListener, as a result we implemented out own fireEmitter (hence the different nesting of the fireEmitter). Though we know this isn't ideal, we could not come up with a way to have RadioButtonGroupMember use FireListener (the PressListener subtype). The rename recognizes that they use two different listeners, but also now since "fire" is in the listener name, it seems more clear that both have a fireEmitter, just in a different hierarchy.

Perhaps one day these two types will be rewritten to be unified. Then we will have the change to also unify the PhET-iO interfaces. After attempting to hammer these two very different implementation into the same PhET-iO api, we felt like this, though not ideal, was the best cost/benefit solution.

@pixelzoom
Copy link
Contributor Author

Thanks for the clarification.

I don't think this issue should be closed -- these implementation do need to be unified, which is the subject of #523. And unfortunately that unification likely requires breaking every PhET-iO API that uses radio buttons.

I've added this issue to the list of issues to be addressed in #523 (comment) (unify radio button group implementations). In the meantime, I'll unassign this issue.

@zepumph
Copy link
Member

zepumph commented Jan 12, 2020

Final thoughts on this issue before it is kicked off to be done with general radio button consolidation.

  1. I really like the instrumentation of AquaRadioButton and its members. In the future I hope that RadioButtonGroup can be converted over to this pattern.
  2. Because of this, I do not think this issue should block publication of Gravity Force Lab, which has a VerticalAquaRadioButtonGroup and no RadioButtonGroup.
  3. Leaving unassigned.

@pixelzoom
Copy link
Contributor Author

  1. Because of this, I do not think this issue should block publication of Gravity Force Lab, which has a VerticalAquaRadioButtonGroup and no RadioButtonGroup.

You're assuming that the linked Property is going to continue to live at the group level. Imo that's not a done deal and needs to be revisited in #549. If it changes, that will break GFL API.

@zepumph
Copy link
Member

zepumph commented Jan 21, 2020

Noting a conversation that @samreid and I had about the imminent publication of gravity force lab with phet-io. We feel like the current instrumentation of AquaRadioButton makes sense, and since consolidation over in #523 will take longer than the time line of GFL, we think that this should not block its publication. The future implementation of radio buttons should embody similar features of this implementation, and so even if the API changes, it will likely not be a 180 flip from the current instrumentation strategy.

@samreid
Copy link
Member

samreid commented Dec 30, 2024

Standardization of the linked element for AquaRadioButtonGroup and RectangularRadioButtonGroup was addressed in #920. @zepumph has been working on pruning the listeners/emitters and I asked him about it in #920 (comment)

So I think this issue can be reviewed with #920. @zepumph anything else to do here?

@arouinfar
Copy link
Contributor

Not sure why the Monday bot assigned this to me, so unassigning myself.

@arouinfar arouinfar removed their assignment Jan 6, 2025
@zepumph
Copy link
Member

zepumph commented Jan 10, 2025

Things are looking really good here. They have now aligned, and are quite simple, each are composed of just a visibleProperty and a firedEmitter. Closing

@zepumph zepumph closed this as completed Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants