You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @elihart, I have a ModelView with a ToggleButton and I wanted to preserve the on/off state of it so I remembered of the existence of saveViewState and based on the wiki thought it would be the solution. I made sure my models had VERY unique ids, so I was expecting that by just setting saveViewState to true the state would be preserved just for that particular model and I wouldn't experience the classical recycling issue (a change on item A can be seen on item F if F is a recycled instance of A and the view wasn't "reset"). So I ran the app and found out that if I change the toggle state on the first item to ON, as I scroll down the list I keep seeing multiple items with the toggle being ON when the default state of it is OFF.
Long story short, I ended up using a mix of saveViewState and @OnViewRecycled where I change back the toggle state to OFF and this seems to solve the issue, but I really was expecting saveViewState to actually save the state of just one ModelView and decide based on the ID of it if to apply the saved state or not. If this (the way I ended up doing it) is the intended behavior then I think the wiki should be updated to reflect it. If not then I believe there's an issue with how saveViewState is working.
The text was updated successfully, but these errors were encountered:
Thanks for the report. I hadn't thought about this case before; you're right, we don't reset view state of views when they are unbound. To do this I believe we would need to save the view's state when it was first created (to have something that declares the default state) and reapply that before the view is bound to a model (if it doesn't have other saved state already).
I think this is reasonable and not too hard. I will try to work on it soon.
I have a fix in mind that should work well, but I've been a bit swamped with work, and have some vacation coming up the next week, so I won't be able to get it in for a little while still.
#367 makes the change to ensure a view has a clean state when a model is first bound. let me know if you notice any new issues or if this does not resolve it!
Hey @elihart, I have a
ModelView
with aToggleButton
and I wanted to preserve the on/off state of it so I remembered of the existence ofsaveViewState
and based on the wiki thought it would be the solution. I made sure my models had VERY unique ids, so I was expecting that by just settingsaveViewState
to true the state would be preserved just for that particular model and I wouldn't experience the classical recycling issue (a change on item A can be seen on item F if F is a recycled instance of A and the view wasn't "reset"). So I ran the app and found out that if I change the toggle state on the first item to ON, as I scroll down the list I keep seeing multiple items with the toggle being ON when the default state of it is OFF.Long story short, I ended up using a mix of
saveViewState
and@OnViewRecycled
where I change back the toggle state to OFF and this seems to solve the issue, but I really was expectingsaveViewState
to actually save the state of just oneModelView
and decide based on the ID of it if to apply the saved state or not. If this (the way I ended up doing it) is the intended behavior then I think the wiki should be updated to reflect it. If not then I believe there's an issue with howsaveViewState
is working.The text was updated successfully, but these errors were encountered: