Skip to content

Commit 618f599

Browse files
committed
Improve parent/child tag logic
1 parent 4166736 commit 618f599

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/app/components/elements/layout/SidebarLayout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { above, ACCOUNT_TAB, ACCOUNT_TABS, AUDIENCE_DISPLAY_FIELDS, below, BOARD
77
EventStatusFilter, EventTypeFilter, filterAssignmentsByStatus, filterAudienceViewsByProperties, getDistinctAssignmentGroups, getDistinctAssignmentSetters, getHumanContext, getThemeFromContextAndTags, HUMAN_STAGES,
88
ifKeyIsEnter, isAda, isDefined, PHY_NAV_SUBJECTS, isTeacherOrAbove, QuizStatus, siteSpecific, TAG_ID, tags, STAGE, useDeviceSize, LearningStage, HUMAN_SUBJECTS, ArrayElement, isFullyDefinedContext, isSingleStageContext,
99
Item, stageLabelMap, extractTeacherName, determineGameboardSubjects, PATHS, getQuestionPlaceholder, getFilteredStageOptions,
10-
isPhy} from "../../../services";
10+
isPhy, TAG_LEVEL} from "../../../services";
1111
import { StageAndDifficultySummaryIcons } from "../StageAndDifficultySummaryIcons";
1212
import { mainContentIdSlice, selectors, useAppDispatch, useAppSelector, useGetQuizAssignmentsAssignedToMeQuery } from "../../../state";
1313
import { Link, useHistory, useLocation } from "react-router-dom";
@@ -336,12 +336,12 @@ const FilterCheckbox = (props : FilterCheckboxProps) => {
336336

337337
const handleCheckboxChange = (checked: boolean) => {
338338
// Reselect parent if all children are deselected
339-
const siblingTags = tag.type === "field" && incompatibleTags ? tags.getDirectDescendents(incompatibleTags[0].id).filter(t => t !== tag) : [];
340-
const reselectParent = siblingTags.length && !siblingTags.some(t => conceptFilters.includes(t));
339+
const siblingTags = tag.type === TAG_LEVEL.field && tag.parent ? tags.getDirectDescendents(tag.parent).filter(t => t !== tag) : [];
340+
const reselectParent = tag.parent && siblingTags.every(t => !conceptFilters.includes(t));
341341

342342
const newConceptFilters = checked
343343
? [...conceptFilters.filter(c => !incompatibleTags?.includes(c)), ...(!partiallySelected ? [tag] : [])]
344-
: [...conceptFilters.filter(c => ![tag, ...(dependentTags ?? [])].includes(c)), ...(reselectParent ? [incompatibleTags![0]] : [])];
344+
: [...conceptFilters.filter(c => ![tag, ...(dependentTags ?? [])].includes(c)), ...(reselectParent ? [tags.getById(tag.parent!)] : [])];
345345
setConceptFilters(newConceptFilters.length > 0 ? newConceptFilters : (baseTag ? [baseTag] : []));
346346
};
347347

0 commit comments

Comments
 (0)