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

Number display incorrect when using array to set balls #335

Closed
Tracked by #1134 ...
Nancy-Salpepi opened this issue Aug 1, 2024 · 7 comments
Closed
Tracked by #1134 ...

Number display incorrect when using array to set balls #335

Nancy-Salpepi opened this issue Aug 1, 2024 · 7 comments

Comments

@Nancy-Salpepi
Copy link

Test device
MacBook Air M1 chip

Operating System
14.5

Browser
Safari 17.5

Problem description
For phetsims/qa#1121, on the Balance Point screen only, the number display doesn't change to show the number of balls on the field when using the array method to add balls.

Steps to reproduce

  1. In Studio, go to the Balance Point Screen
  2. In the console paste: await phetioClient.invokeAsync( 'meanShareAndBalance.balancePointScreen.model', 'setDataPoints', [ [4, 9, 10, 1, 10, 6,] ] );

Visuals
Screenshot 2024-08-01 at 8 11 11 AM

@marlitas
Copy link
Contributor

marlitas commented Aug 5, 2024

Addressed above. I would like to talk with over with @jbphet though.

@marlitas marlitas removed their assignment Aug 5, 2024
@jbphet
Copy link
Contributor

jbphet commented Aug 12, 2024

This change is a little tricky for me to review. I can see what you're after (I think) in BalancePointSceneModel.setDataPoints with the lines:

    this.targetNumberOfBallsProperty.value = Math.min( dataPoints.length, this.maxKicksProperty.value );
    this.numberOfQueuedKicksProperty.value = 0;

Reading through other parts of the code, I can see that changing targetNumberOfBallsProperty could queue up some balls for kicking, thus changing the value of numberOfQueuedKicksProperty, so you then need to prevent that from actually happening by setting numberOfQueuedKicksProperty to 0. It sure feels fragile though, since it relies on an understanding of how these two Properties interact within the context of the model. I looked at the handler for changes to targetNumberOfBallsProperty, and I think this is safe, but I didn't scan through the code for listeners to numberOfQueuedKicksProperty that could potentially be messed up by all of this.

Since this is a phet-io-specific feature, I think it's probably okay, but I'd suggest elaborating the existing comment a bit to describe a bit more fully what's going on.

@jbphet jbphet assigned marlitas and unassigned jbphet Aug 12, 2024
marlitas added a commit that referenced this issue Aug 13, 2024
@marlitas
Copy link
Contributor

Committed more documentation. I believe this is ready for cherry-pick. @jbphet let's connect synchronously to make sure we are indeed good to go on this. I agree that it feels fragile... it was not my favorite overall. I would feel better if the method could be private or protected, but that does not appear to be possible either.

@marlitas
Copy link
Contributor

Met with @jbphet and we both agreed it was a necessary evil. @pixelzoom helped us by pointing out that moving the override code to the BalancePointModel IOType would increase the safety of the code. We feel much better now.

marlitas added a commit that referenced this issue Aug 13, 2024
marlitas added a commit that referenced this issue Aug 13, 2024
(cherry picked from commit 8a95836)
marlitas added a commit that referenced this issue Aug 13, 2024
marlitas added a commit to phetsims/soccer-common that referenced this issue Aug 14, 2024
@Nancy-Salpepi
Copy link
Author

Unable to verify this issue is fixed due to #345

@jbphet jbphet assigned jbphet and unassigned jbphet Aug 15, 2024
@jbphet
Copy link
Contributor

jbphet commented Aug 19, 2024

#345 is now, I believe, fixed. I verified that this issue (i.e. #335) is fixed on main, and it's lookin' good, so I think this will be ready to verify in the next RC.

@KatieWoe
Copy link

Looks good in rc.3

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

4 participants