From c85bdcf9114f7d8f924ea1abd2ae51ce3b3f4c57 Mon Sep 17 00:00:00 2001 From: tejaswiverma Date: Thu, 17 Sep 2026 23:46:10 +0530 Subject: [PATCH] fix(resources): associate filter checkboxes with labels explicitly Add category-scoped unique IDs and matching htmlFor attributes to checkbox filters using x.id to prevent whitespace and ensure proper accessibility association. Signed-off-by: tejaswiverma --- .../Resources/Resources-grid/filters.js | 356 ++++++++++-------- 1 file changed, 198 insertions(+), 158 deletions(-) diff --git a/src/sections/Resources/Resources-grid/filters.js b/src/sections/Resources/Resources-grid/filters.js index 795f42f2ad5b4d..3b47775d9b5ca7 100644 --- a/src/sections/Resources/Resources-grid/filters.js +++ b/src/sections/Resources/Resources-grid/filters.js @@ -6,47 +6,65 @@ import { FiFilter } from "@react-icons/all-files/fi/FiFilter"; import { options } from "./options"; import { graphql, useStaticQuery } from "gatsby"; - import ResourceNavigationWrapper from "./filters.style"; const Navigation = (props) => { - - const counting = useStaticQuery( - graphql`query allFilters { - type: allMdx( - filter: {fields: {collection: {in: ["blog", "resources", "news", "events"]}}, frontmatter: {published: {eq: true}, resource: {eq: true}}} - ) { - group(field: {frontmatter: {type: SELECT}}) { - fieldValue - totalCount - } - } - product: allMdx( - filter: {fields: {collection: {in: ["blog", "resources", "news", "events"]}}, frontmatter: {published: {eq: true}, resource: {eq: true}}} - ) { - group(field: {frontmatter: {product: SELECT}}) { - fieldValue - totalCount - } - } - technology: allMdx( - filter: {fields: {collection: {in: ["blog", "resources", "news", "events"]}}, frontmatter: {published: {eq: true}, resource: {eq: true}}} - ) { - group(field: {frontmatter: {technology: SELECT}}) { - fieldValue - totalCount + const counting = useStaticQuery(graphql` + query allFilters { + type: allMdx( + filter: { + fields: { + collection: { in: ["blog", "resources", "news", "events"] } + } + frontmatter: { published: { eq: true }, resource: { eq: true } } + } + ) { + group(field: { frontmatter: { type: SELECT } }) { + fieldValue + totalCount + } + } + product: allMdx( + filter: { + fields: { + collection: { in: ["blog", "resources", "news", "events"] } + } + frontmatter: { published: { eq: true }, resource: { eq: true } } + } + ) { + group(field: { frontmatter: { product: SELECT } }) { + fieldValue + totalCount + } + } + technology: allMdx( + filter: { + fields: { + collection: { in: ["blog", "resources", "news", "events"] } + } + frontmatter: { published: { eq: true }, resource: { eq: true } } + } + ) { + group(field: { frontmatter: { technology: SELECT } }) { + fieldValue + totalCount + } + } + mesh: allMdx( + filter: { + fields: { + collection: { in: ["blog", "resources", "news", "events"] } + } + frontmatter: { published: { eq: true }, resource: { eq: true } } + } + ) { + group(field: { frontmatter: { mesh: SELECT } }) { + fieldValue + totalCount + } + } } - } - mesh: allMdx( - filter: {fields: {collection: {in: ["blog", "resources", "news", "events"]}}, frontmatter: {published: {eq: true}, resource: {eq: true}}} - ) { - group(field: {frontmatter: {mesh: SELECT}}) { - fieldValue - totalCount - } - } -}` - ); + `); const [expandFilter, setExpandFilter] = useState(false); const [expandType, setExpandType] = useState(true); @@ -64,186 +82,208 @@ const Navigation = (props) => { const technologies = [...new Set(counting.technology.group)]; const meshes = counting.mesh.group; - return (
-
{ - setExpandFilter(!expandFilter); - }} className="filter-menu-icon" +
{ + setExpandFilter(!expandFilter); + }} + className="filter-menu-icon" > {expandFilter ? ( - ) : - ( - - )} + ) : ( + + )}
-

+

Filters - + Clear Filters - {expandFilter ? ( - Clear Filters - ) : ""} + {expandFilter ? ( + + Clear Filters + + ) : ( + "" + )}

-
-

Type

+

+ Type +

{expandType ? ( - + ) : ( - + )}
    - {typeOptions[0].subdata.map((x) => ( -
  • - -
  • - ))} + {typeOptions[0].subdata.map((x) => { + const type = + types && types.find((t) => t.fieldValue === x.value); + const filterId = `type-${x.id}`; + return type ? ( +
  • + +
  • + ) : null; + })}
-
-

Product

+

+ Product +

{expandProduct ? ( - + ) : ( - + )}
    - {productOptions[0].subdata.map((x) => ( -
  • - -
  • - ))} + {productOptions[0].subdata.map((x) => { + const product = + products && products.find((p) => p.fieldValue === x.value); + const filterId = `product-${x.id}`; + return product ? ( +
  • + +
  • + ) : null; + })}
-
-

Technology

+

+ Technology +

{expandTech ? ( - + ) : ( - + )}
    - {techOptions[0].subdata.map((x) => ( -
  • - -
  • - ))} + {techOptions[0].subdata.map((x) => { + const technology = + technologies && + technologies.find((t) => t.fieldValue === x.value); + const filterId = `technology-${x.id}`; + return technology ? ( +
  • + +
  • + ) : null; + })}
-
-

Service Mesh

+

+ Service Mesh +

{expandMesh ? ( - + ) : ( - + )}
    - {meshOptions[0].subdata.map((x) => ( -
  • - -
  • - ))} + {meshOptions[0].subdata.map((x) => { + const mesh = + meshes && meshes.find((m) => m.fieldValue === x.value); + const filterId = `mesh-${x.id}`; + return mesh ? ( +
  • + +
  • + ) : null; + })}
- -
- ); };