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

First "+" button doesn't go through for params that can have dims added #311

Open
MaxGhenis opened this issue Aug 4, 2020 · 5 comments
Open

Comments

@MaxGhenis
Copy link
Contributor

For example, in https://github.com/PSLmodels/OG-USA/issues/611 I mentioned the TFP param, which looks like this by default:
image

After hitting the + once, it shows as if something's changed, but stays as one dim:
image

Hitting it again shows the additional dim:
image

@hdoupe
Copy link
Contributor

hdoupe commented Aug 4, 2020

@MaxGhenis thanks for opening this issue.

The behavior I had in mind was:

  • If you click the plus button, then it sets the first value. If you click it again, then it extends it. That is, the value is empty initially and clicking "Plus" extends from 0 to 1 values. The change in color indicates that the value is has been "edited."
  • If you type something into the input box and then click the plus button, then it will be extended immediately.

However, if the behavior needs an explanation, then there is probably something wrong with it. Do you think the first click on an empty array field should set two values for the array?

@MaxGhenis
Copy link
Contributor Author

If you click the plus button, then it sets the first value.

In this case though, the first value is already set. What does clicking it the first time do?

@hdoupe
Copy link
Contributor

hdoupe commented Aug 5, 2020

@MaxGhenis This is what I was thinking when I made the array fields. I think it helps to think about the adjustment JSON object that is being created behind the scenes as the array field is updated.

Case 1: User clicks + without typing

  1. Initially, The list is empty:
    image
{ 
    "Z": [
        {
            "value": []
        }
    ]
}
  1. Clicking plus updates "Z":

image

{
    "Z": [
        {
            "value": [1]
        }
    ]
}
  1. Clicking twice gives:

image

}
    "Z": [
        {
            "value": [1, 1]
        }
    ]
}

If I changed the + behavior to automatically add 2 elements, then the data behind the scenes would skip to step 3.

Case 2: User types a number and then clicks +

  1. User types 1 and sets the first value

Screenshot from 2020-08-05 11-09-41

{
    "Z": [
        {
            "value": [1]
        }
    ]
}
  1. User clicks + and extends the first value to the second element of the list:
    Screenshot from 2020-08-05 11-09-50
}
    "Z": [
        {
            "value": [1, 1]
        }
    ]
}

@hdoupe
Copy link
Contributor

hdoupe commented Aug 5, 2020

^ I don't think this is necessarily the best way to do this. I think there is something missing from the UI that indicates that clicking the "+" button updates the parameter from an empty list to a list with one element.

But, I do think that the behavior right now is at least consistent.

@MaxGhenis
Copy link
Contributor Author

Per our chat, this is because the reform parameterization starts off as [], even if the value when running the simulation will be [1]. This stems from a more general design decision to treat parameters as reforms upon interaction rather than upon changing away from the default value. I suggested changing that behavior in #314, and IMO this issue (#311) could be addressed separately from that, but they're both low priority on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants