Skip to content

Commit 3a56b3e

Browse files
authored
Update sanitize-row.js
1 parent 6d3803f commit 3a56b3e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/table/helpers/sanitize-row.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ const IGNORED = keys(IGNORED_FIELD_KEYS)
99

1010
// Return a copy of a row after all reserved fields have been filtered out
1111
const sanitizeRow = (row, ignoreFields, includeFields, fieldsObj = {}) => {
12+
includeFields = concat(includeFields).filter(identity)
1213
const ignore = concat(IGNORED, ignoreFields).filter(identity)
13-
const include = isArray(includeFields) && includeFields.length > 0 ? includeFields : null
14+
const allowedKeys = keys(row)
15+
.filter(k => !arrayIncludes(ignore, k))
16+
.filter(k => arrayIncludes(includeFields, k))
1417
return keys(row).reduce((obj, key) => {
18+
// Filter top level keys in the row
1519
// Ignore special fields that start with `_`
1620
// Ignore fields in the `ignoreFields` array
1721
// Include only fields in the `includeFields` array (if present)
18-
if (!arrayIncludes(ignore, key) && !(include && !arrayIncludes(include, key))) {
22+
if (arrayIncludes(allowedKeys, key)) {
1923
const f = fieldsObj[key] || {}
2024
const val = row[key]
2125
// `f.filterByFormatted` will either be a function or boolean

0 commit comments

Comments
 (0)