diff --git a/lib/session.js b/lib/session.js index 8f5f64beb2..98ca1d24df 100644 --- a/lib/session.js +++ b/lib/session.js @@ -59,7 +59,7 @@ function storeData (input, data) { let val = input[i] // Delete values when users unselect checkboxes - if (val === '_unchecked' || val === ['_unchecked']) { + if ([val].flat().every((item) => item === '_unchecked')) { delete data[i] continue } diff --git a/lib/session.test.js b/lib/session.test.js index ca851c6a7a..feacb8483e 100644 --- a/lib/session.test.js +++ b/lib/session.test.js @@ -89,7 +89,7 @@ describe('autoStoreData', () => { } const expectedData = { checkBoxes1: ['cb1-1', 'cb1-2'], - checkBoxes2: [], + checkBoxes2: undefined, checkBoxes3: ['cb3-1', 'cb3-2'], existingData: 'existing data' }