Skip to content

Commit

Permalink
Merge pull request #1095 from akvo/feature/1094-village-list-has-only…
Browse files Browse the repository at this point in the history
…-one-option-when-switching-dep-questions

[#1094]  Village list has only one option when switching from update to new form
  • Loading branch information
dedenbangkit authored Jan 29, 2024
2 parents 84c3e4e + f8a9f52 commit c8b7c33
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/form/fields/TypeCascade.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ const TypeCascade = ({

const initialDropdowns = useMemo(() => {
const parentIDs = source?.parent_id?.length ? source.parent_id : [0];
let filterDs = dataSource.filter(
const filterDs = dataSource.filter(
(ds) =>
parentIDs.includes(ds?.parent) || value?.includes(ds?.id) || value?.includes(ds?.parent),
parentIDs.includes(ds?.parent) ||
parentIDs.includes(ds?.id) ||
value?.includes(ds?.id) ||
value?.includes(ds?.parent),
);
if (filterDs.length === 0) {
filterDs = dataSource.filter((ds) => parentIDs.includes(ds?.id));
}
const groupedDs = groupBy(filterDs, 'parent');
if (parentIDs.length > 1 && Object.keys(groupedDs).length > 1) {
const parentOptions = Object.keys(groupedDs).map((keyID) =>
Expand Down

0 comments on commit c8b7c33

Please sign in to comment.