From 4fc598c9ab0de1d0b4fa3ca86dc9834ef3535b90 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 19 Sep 2025 19:11:32 +0000 Subject: [PATCH 1/2] Initial plan From 650e8ba266c1d66f97d231c1c030838d6b5e8b14 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 19 Sep 2025 19:20:58 +0000 Subject: [PATCH 2/2] Implement exact match prioritization in select search Co-authored-by: NickCrews <10820686+NickCrews@users.noreply.github.com> --- .../components/editor/select/EditorMain.tsx | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/components/editor/select/EditorMain.tsx b/packages/sdk/src/components/editor/select/EditorMain.tsx index 389375baca..1d243be1b7 100644 --- a/packages/sdk/src/components/editor/select/EditorMain.tsx +++ b/packages/sdk/src/components/editor/select/EditorMain.tsx @@ -57,7 +57,28 @@ const SelectEditorMainBase: ForwardRefRenderFunction< const filteredOptions = useMemo(() => { if (!searchValue) return options; - return options.filter((v) => v.label.toLowerCase().includes(searchValue.toLowerCase())); + const searchLower = searchValue.toLowerCase(); + const filtered = options.filter((v) => v.label.toLowerCase().includes(searchLower)); + + // Sort to prioritize exact matches and prefix matches + return filtered.sort((a, b) => { + const aLabelLower = a.label.toLowerCase(); + const bLabelLower = b.label.toLowerCase(); + + // Check for exact matches first + if (aLabelLower === searchLower && bLabelLower !== searchLower) return -1; + if (bLabelLower === searchLower && aLabelLower !== searchLower) return 1; + + // Check for prefix matches + const aStartsWith = aLabelLower.startsWith(searchLower); + const bStartsWith = bLabelLower.startsWith(searchLower); + + if (aStartsWith && !bStartsWith) return -1; + if (bStartsWith && !aStartsWith) return 1; + + // If both start with search or neither does, maintain original order + return 0; + }); }, [options, searchValue]); const onSelect = (val: string) => {