Skip to content

Commit

Permalink
Merge pull request #1474 from culturecreates/hotfix/issue-1469
Browse files Browse the repository at this point in the history
Hotfix/issue 1469
  • Loading branch information
sahalali authored Nov 28, 2024
2 parents df4fd78 + a20190c commit c359e84
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/utils/removeUneditedFallbackValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,32 @@ export const filterUneditedFallbackValues = ({
};

const emptyValueFilter = (additionalFilters, modifiedValues) => {
if (additionalFilters && Object.values(additionalFilters).some((value) => value === true)) {
if (
typeof additionalFilters !== 'object' ||
typeof modifiedValues !== 'object' ||
!additionalFilters ||
!modifiedValues
) {
return undefined;
}

const modifiedValuesCopy = { ...modifiedValues };

if (Object.values(additionalFilters).some((value) => value === true)) {
Object.keys(additionalFilters).forEach((key) => {
if (Object.prototype.hasOwnProperty.call(modifiedValues, key)) {
if (Object.prototype.hasOwnProperty.call(modifiedValuesCopy, key)) {
if (additionalFilters[key] === false) {
delete modifiedValues[key];
delete modifiedValuesCopy[key];
}
}
});
}

return modifiedValues;
Object.keys(modifiedValuesCopy).forEach((key) => {
if (typeof modifiedValuesCopy[key] === 'string' && modifiedValuesCopy[key].trim() === '') {
delete modifiedValuesCopy[key];
}
});

return Object.keys(modifiedValuesCopy).length ? modifiedValuesCopy : undefined;
};

0 comments on commit c359e84

Please sign in to comment.