Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/app-webdir-ui/src/SearchPage/components/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")}`;
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern [^a-zA-Z0-9-_] allows hyphens and underscores but React's useId() can generate colons which are valid in CSS selectors but should be escaped. Consider using [^a-zA-Z0-9_] to remove hyphens as well, or handle colon escaping specifically if CSS targeting is needed.

Suggested change
const sortLabelId = `sortBy-${rawSortLabelId.replace(/[^a-zA-Z0-9-_]/g, "")}`;
const sortLabelId = `sortBy-${rawSortLabelId.replace(/[^a-zA-Z0-9-_]/g, "").replace(/:/g, "")}`;

Copilot uses AI. Check for mistakes.


const sortOptions = customSortOptions || [
{ value: "_score_desc", label: "Relevancy" },
{ value: "last_name_asc", label: "Last Name (ascending)" },
Expand Down