phetsims / natural-selection

"Natural Selection" is an educational simulation in HTML5, by PhET Interactive Simulations
GNU General Public License v3.0
3 stars 7 forks source link

Population panel checkboxes do not remain unchecked in launched sim #314

Closed Nancy-Salpepi closed 1 year ago

Nancy-Salpepi commented 2 years ago

Test device MacBook Air m1 chip

Operating System macOS 12.4

Browser Safari

Problem description For https://github.com/phetsims/qa/issues/818, after selecting mutations, any checkboxes I then uncheck in the Population panel will be checked in the launched sim. The only exceptions are the Total checkbox and Data Probe checkbox. This happens on both screens and can be seen in both Studio and State wrappers.

This is also seen in version 1.4.3

Steps to reproduce

  1. In the Studio wrapper, go to the Intro screen
  2. Add the fur mutation
  3. Uncheck the Brown Fur and White Fur checkboxes in the Population panel
  4. Press the Preview Sim button

Visuals

https://user-images.githubusercontent.com/87318828/178357428-40cfe7b6-f4e9-4e54-9c8c-e11aab3dd03b.mp4

Nancy-Salpepi commented 2 years ago

This also happens with the Alleles panel.

Screen Shot 2022-07-11 at 5 06 37 PM Screen Shot 2022-07-11 at 5 05 55 PM
Nancy-Salpepi commented 2 years ago

When in the State wrapper, if I press the Set State Now button a second time, the checkboxes will become unchecked.

https://user-images.githubusercontent.com/87318828/178361135-a2941c07-05fc-4193-88cd-ff3435fc5e5b.mp4

pixelzoom commented 2 years ago

A little confusing because the steps describe the Intro screen, but checkboxes2.mp4 shows the Lab screen, and does not show all of the steps. But reproduced in https://phet-dev.colorado.edu/html/natural-selection/1.5.0-dev.1/phet-io/wrappers/studio/ and master.

This problem is also present in the previous version, https://phet-dev.colorado.edu/html/natural-selection/1.4.3/phet-io/wrappers/studio/. So it's probably an ordering dependency in how state is restored. I'm guessing that the state of the Properties associated with the checkboxes is restored first. Then state related to the fur mutation is restored, and it sets the state of Properties associated with the checkboxes to true -- and that bit probably needs to be surround with an "if not setting state" check.

The problem reported in the Alleles panel is almost certainly the same issue.

pixelzoom commented 2 years ago

Btw... When pressing the "Set State Now" button a second time, the allele is already in the correct state, so its listener does not fire, and does not change the state of the Properties associated with the checkboxes. The checkboxes therefore end up in the correct state.

pixelzoom commented 2 years ago

Fixed in the above commit by checking if ( !phet.joist.sim.isSettingPhetioStateProperty.value ) where appropriate.

@Nancy-Salpepi please verify in master. If it looks OK, change the label to status:fixed-awaiting-deploy and unassigned.

Nancy-Salpepi commented 2 years ago

Looks good on master. Sorry for the confusion with the original video.

pixelzoom commented 1 year ago

To verify in https://github.com/phetsims/qa/issues/967, follow the steps in https://github.com/phetsims/natural-selection/issues/314#issue-1301221663.

Please close this issue if it verifies OK.

Nancy-Salpepi commented 1 year ago

This looks good in 1.5.0-dev.5. Closing.