From 4c30f84a1144a1731d29cc0d5b1a0159f4676186 Mon Sep 17 00:00:00 2001 From: Juan Pablo Mitriatti Date: Mon, 25 Aug 2025 13:48:43 -0300 Subject: [PATCH] fix(app-webdir-ui): sanitize useId to generate accessible form field IDs UDS-2046 --- packages/app-webdir-ui/src/SearchPage/components/sort.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/app-webdir-ui/src/SearchPage/components/sort.js b/packages/app-webdir-ui/src/SearchPage/components/sort.js index 0bbdaf1082..521b26ff12 100644 --- a/packages/app-webdir-ui/src/SearchPage/components/sort.js +++ b/packages/app-webdir-ui/src/SearchPage/components/sort.js @@ -16,7 +16,10 @@ import { SortLayout } from "./index.styles"; const SortPicker = ({ sort, onChange, customSortOptions }) => { const [defaultSortValue, setDefaultSortValue] = useState(sort); - const sortLabelId = useId(); + + const rawSortLabelId = useId(); + const sortLabelId = `sortBy-${rawSortLabelId.replace(/[^a-zA-Z0-9-_]/g, "")}`; + const sortOptions = customSortOptions || [ { value: "_score_desc", label: "Relevancy" }, { value: "last_name_asc", label: "Last Name (ascending)" },