foxhound87 / mobx-react-form

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

empty strings in array aren't preserved on values() #544

Closed SangilYun closed 1 year ago

SangilYun commented 4 years ago

Version "mobx-react": "5.4.3", "mobx-react-form": "1.35.1",

Example 1

const fields = {
    testField: ['', ''],
  };

const form = new MobxReactForm({ fields });
console.log('test form values', form.values()); //returns {testField:[]}

Example 2

const fields = {
    testField: ['', '1', ''],
  };

const form = new MobxReactForm({ fields });
console.log('test form values', form.values()); //returns {testField:['1']}

I was expecting Example 1 would return {testField: ['', '']} and Example 2 return {testField: ['', '1', '']}, but it seems like empty strings get trimmed out when the values function is called

how can I keep the empty strings?

foxhound87 commented 2 years ago

I will work on a form option to handle and keep both cases

foxhound87 commented 1 year ago

removeNullishValuesInArrays form option has been introduced in 5.4.0