Open pixelzoom opened 2 years ago
A few things...
PhET-iO is probably restoring Dialog isShowingProperty
, and that's not doing the same thing as the user opening the dialog.
Dialog has option hideCallback
, which should probably be used instead of AmplitudeKeypadDialog's this.closeCallback
.
AmplitudeKeypadDialog overrides show
and changes its signature. That seems problematic. I.e.:
show( order, enterCallback, closeCallback ) {
// ... do stuff specific to AmplitudeKeypadDialog
super.show();
}
closeCallback
and enterCallback
are needed. It would be easier to avoid this problem by creating one AmplitudeKeypadDialog instance per amplitude. But then we'd have 22 instances of AmplitudeKeypadDialog, instead of 2.It would be easier to avoid this problem by creating one AmplitudeKeypadDialog instance per amplitude.
I investigated this approach, and it looks promising. But it was not entirely straightforward, and I ran into problems with emphasized harmonics not behaving properly, followed by a crash. So I bailed for now, and will defer until we resume work on this sim.
When this sim was converted to TypeScript in https://github.com/phetsims/fourier-making-waves/commit/600727cafa89370ef97ef8a664e033aeaa1aaaa3, the following change was made:
public override hide(): void {
super.hide();
this.interruptSubtreeInput();
- this.closeCallback();
+ this.closeCallback && this.closeCallback();
This fixed the crash during fuzzing. But the list of emphasized harmonics (managed via enterCallback
and closeCallback
) is not getting updated because state is just setting isShowingProperty
.
So I'll leave this issue open, to be investigated when work resumes on a PhET-iO version of this sim.
When fuzz testing the State wrapper with
phet-io-wrappers/state/?sim=fourier-making-waves&phetioDebug&fuzz
, this error occurs:AmplitudeKeypadDialog is this dialog, opened by pressing on one of the amplitude values shown above the amplitude sliders.
AmplitudeKeypadDialog has field
this.closeCallback
. It's set whenshow
is called, then called (and cleared) whenhide
is called. So what I guess is happening is that the dialog is somehow being opened by the State wrapper without callingshow
.AmplitudeKeypadDialog has another field,
this.enterCallback
, that I suspect would have a similar problem. It's set whenshow
is called, then called (and cleared) when the Enter button is pressed.