-
Notifications
You must be signed in to change notification settings - Fork 35
Description
🐛 Bug Report
When working with Visibility
, toggling between removing a value using useData().remove()
when hiding and then showing the fields related to to removed value causes an error.
I notice that after removing a value, it's not actually removed, but is set to undefined
.
In another case, which is not relevant any more, I used set()
to get the value properly removed from the data, but I don't think that is a very elegant solution.
Could/should remove()
remove the key as well as the value from the data?
Or are there better ways to handle removing values when hiding them to avoid them being part of submitted data?
TypeError
Cannot use 'in' operator to search for '1' in undefined
at Object.set (https://swf6zr.csb.app/node_modules/
dnb/eufemia/extensions/forms/utils/json-pointer/json-pointer.js:45:16
at eval (https://swf6zr.csb.app/node_modules/
dnb/eufemia/extensions/forms/DataContext/Provider/Provider.js:426:28
at eval (https://swf6zr.csb.app/node_modules/
dnb/eufemia/extensions/forms/hooks/useFieldProps.js:1011:95
at eval (https://swf6zr.csb.app/node_modules/
dnb/eufemia/extensions/forms/hooks/useFieldProps.js:1039:7
commitHookEffectListMount
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:23150:26
commitLayoutEffectOnFiber
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:23268:17
commitLayoutMountEffects_complete
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:24688:9
commitLayoutEffects_begin
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:24674:7
commitLayoutEffects
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:24612:3
commitRootImpl
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:26823:5
commitRoot
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:26682:5
performSyncWorkOnRoot
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:26117:3
flushSyncCallbacks
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:12042:22
eval
https://swf6zr.csb.app/node_modules/react-dom/cjs/react-dom.development.js:25651:13
Screen.Recording.2024-10-30.at.10.35.58.mov
To Reproduce
Steps to reproduce the behavior:
https://codesandbox.io/p/sandbox/remove-data-on-hide-swf6zr
Expected behavior
I expect the Fields
to initialize the same way they do when they are first rendered when I show them after having removed them via remove()
.
Eufemia Version
10.53.0