From 2a0c4ce59a1342ba4ee85108e4ac845a009c1b3c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 24 May 2026 21:54:43 +0000 Subject: [PATCH] fix: enable skills filtering by selected skills - Updated `UnifiedFilterBar` to use data keys as selection IDs for Areas, Skills, and Roles. - Integrated `selected["skills"]` into the `SkillsSection` filtering logic. - Ensured consistency between filter state and data keys for robust matching. - Verified changes with Playwright and project build/lint checks. --- src/components/sections/skills.tsx | 8 ++++++-- src/components/unified-filter-bar.tsx | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/sections/skills.tsx b/src/components/sections/skills.tsx index 206d5105..b05c5b4b 100644 --- a/src/components/sections/skills.tsx +++ b/src/components/sections/skills.tsx @@ -15,6 +15,7 @@ export const SkillsSection = () => { const { selected } = useFilter(); const areas = selected["areas"]; + const skills = selected["skills"]; // ⚡ Optimization: Memoize areaMatchingSkills separately from the query filter. // This avoids re-calculating the matching skills set when only the search query changes. @@ -30,6 +31,8 @@ export const SkillsSection = () => { return matchingSkills; }, [areas]); + const selectedSkills = useMemo(() => new Set(skills || []), [skills]); + // ⚡ Optimization: filteredSkills now only depends on debouncedQuery and the memoized areaMatchingSkills. const filteredSkills = useMemo(() => { const lowercaseQuery = debouncedQuery.toLowerCase(); @@ -38,9 +41,10 @@ export const SkillsSection = () => { const matchesQuery = !lowercaseQuery || skill.name.toLowerCase().includes(lowercaseQuery); const matchesArea = areaMatchingSkills.has(key); - return matchesQuery && matchesArea; + const matchesSkill = selectedSkills.size === 0 || selectedSkills.has(key); + return matchesQuery && matchesArea && matchesSkill; }); - }, [debouncedQuery, areaMatchingSkills]); + }, [debouncedQuery, areaMatchingSkills, selectedSkills]); return (
diff --git a/src/components/unified-filter-bar.tsx b/src/components/unified-filter-bar.tsx index de41b28a..f074d325 100644 --- a/src/components/unified-filter-bar.tsx +++ b/src/components/unified-filter-bar.tsx @@ -37,8 +37,8 @@ export const UnifiedFilterBar = () => { ({ - id: a.name.toLowerCase(), + values={Object.entries(areas).map(([id, a]) => ({ + id, name: a.name, icon: a.icon, }))} @@ -47,8 +47,8 @@ export const UnifiedFilterBar = () => { /> ({ - id: s.name.toLowerCase(), + values={Object.entries(skills).map(([id, s]) => ({ + id, name: s.name, icon: s.icon, }))} @@ -57,8 +57,8 @@ export const UnifiedFilterBar = () => { /> ({ - id: r.name.toLowerCase(), + values={Object.entries(roles).map(([id, r]) => ({ + id, name: r.name, }))} selected={selected["roles"] || []}