foxhound87 / mobx-react-form

Reactive MobX Form State Management
https://foxhound87.github.io/mobx-react-form
MIT License
1.1k stars 129 forks source link

A field with "/" in the key can not be deleted. #573

Closed r1y4h closed 3 years ago

r1y4h commented 3 years ago

Code snippet:

const key = 'with/forward/slash'
const form = new MobxReactForm()
form.add({
 key,
 type: 'text',
})
form.del(key) //will throw "Cannot read property 'fields' of undefined"

I found the reason inside Utils.js container function where the last item from the path is stripped out by this line of code:

const cpath = _.trim(path.replace(new RegExp('[^./]+$'), ''), '.');

Is this by design, should we avoid using "/" in key? But why does it accept such key (able to add the field) but del fails?

Thanks for any help.