AmbireTech / adex-platform

AdEx Platform UI
https://platform.adex.network
GNU General Public License v3.0
58 stars 19 forks source link

Form not being cleared on toggle. #4

Closed avipatel91 closed 6 years ago

avipatel91 commented 6 years ago

A reopened form that was X'ed out will still have old input if there was any.

avipatel91 commented 6 years ago

I have something here but I don't believe this is the right approach. https://github.com/avipatel91/adex-dapp/commit/3be2ebde7fbaad77cfba9fa9d5c25e47e7bd0057

In order to reset new 'item' state. An item object with the '_type' has to be provided. I used an clean item object from initialState. This item object has '_type' key. This key is then used in the newItemReducer to find a clean item from initialState. We can reduce these steps by just providing type and then newItemReducer would find a clean item from initialState that corresponds to the type.

ivopaunov commented 6 years ago

This behavior is on purpose (in case of accident toggle/close of the form). For every type of new item the state is kept in the memory reducer. I will add "reset form" button or the "reset" can be only on "cancel". Click outside the dialog or on"x" should not clear the form. The form is cleared only on item save at the moment.

avipatel91 commented 6 years ago

Sounds good! I will open up another issue requesting a 'reset button'. If you want me to take it up, I am more than happy to help. =)