Skip to content

Commit

Permalink
[#1094] Fix invalid TypeCascade options
Browse files Browse the repository at this point in the history
Fixed by updating conditional parentIDs & value in single filtering
  • Loading branch information
ifirmawan committed Jan 29, 2024
1 parent 84c3e4e commit f8a9f52
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 f8a9f52

Please sign in to comment.