keepDirtyValues works weird if you have switchable tabs with registered inputs #10963
-
I have a very complex app where I receive data from backend, group it and create tabs for each group. When user adds in one tab n numbers of fields - everything works fine. But if he/she puts some values to inputs in a tab 1, then select tab 2 and there will add more than one new input it will erase dirty values from the tab 1. But most interesting that formState.dirtyFields still will show inputs from tab 1 as dirty but with the initial values. And it happens only if there will be more than one data update. So, if user
Is it correct behaviour that reset(keepDirtyValues) works only on first call if input is not visible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Method Based on your description, it seems like your Tabs component is only render active tab (a.k.a mount/unmount tab based on its active status). A workaround for this case is to switch to visibility by CSS |
Beta Was this translation helpful? Give feedback.
@olegmashalanchuk
Method
reset()
will work even if input is not visibledisplay: none
. It might not work correctly if your visibility is applied by mounting/unmounting the input.Based on your description, it seems like your Tabs component is only render active tab (a.k.a mount/unmount tab based on its active status). A workaround for this case is to switch to visibility by CSS
display: none
to keep reference on input field.