numberscope / frontscope

Numberscope's front end and user interface: responsible for specifying sequences and defining and displaying visualizers
MIT License
7 stars 15 forks source link

Avoid refreshParams trap #443

Closed gwhitney closed 4 weeks ago

gwhitney commented 2 months ago

In https://github.com/orgs/numberscope/discussions/6#discussioncomment-10215660, Kate describes an unfortunate trap in which updating an array of (say) sequence values needs to update the description of a different parameter, e.g. turn angles. Hence it calls refreshParams. But then typing a single space at the end of an existing input for the array ends up deleting the space via the canonicalization of input from refreshParams.

There are two plausible ways out of this trap:

  1. Don't canonicalize input -- if the current value of the tentative parameter would decode into the current value of the actual parameter, leave the tentative value alone.
  2. Add an argument to refreshParams that says which parameter is being refreshed (or no arg for all of them), and don't touch other parameters.

I'd recommend trying 1 first to see if it seems to work OK, as it is much simpler. This improvement is needed for the Turtle overhaul for alpha.

gwhitney commented 4 weeks ago

Apparently #1 is already implemented in ui2: Having a "3" in an input field and inserting a 0 before it to make "03" which used to be canonicalized to "3" now leaves the "03" there. Hence closing this issue.