From 27643c8a37d8980a24e5b959bb3420fab3ac8d53 Mon Sep 17 00:00:00 2001 From: Pedro Bonamin <46196328+pedrobonamin@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:08:45 +0100 Subject: [PATCH] fix(tasks): don't lowercase users when searching in the assignee menu (#6138) --- .../fields/assignee/AssigneeSelectionMenu.tsx | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/packages/sanity/src/tasks/src/tasks/components/form/fields/assignee/AssigneeSelectionMenu.tsx b/packages/sanity/src/tasks/src/tasks/components/form/fields/assignee/AssigneeSelectionMenu.tsx index e79d30e521c..06dd728d260 100644 --- a/packages/sanity/src/tasks/src/tasks/components/form/fields/assignee/AssigneeSelectionMenu.tsx +++ b/packages/sanity/src/tasks/src/tasks/components/form/fields/assignee/AssigneeSelectionMenu.tsx @@ -10,7 +10,6 @@ import { Text, TextInput, } from '@sanity/ui' -import {motion} from 'framer-motion' import {deburr} from 'lodash' import {type ChangeEvent, type KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react' import {LoadingBlock, type UserWithPermission, useTranslation} from 'sanity' @@ -93,17 +92,17 @@ function MentionsMenu({onSelect, value = ''}: {onSelect: SelectItemHandler; valu const deburredOptions = options?.map((option) => ({ ...option, - displayName: deburr(option.displayName || '').toLocaleLowerCase(), + searchName: deburr(option.displayName || '').toLocaleLowerCase(), })) const filtered = deburredOptions ?.filter((option) => { - return option?.displayName?.includes(deburredSearchTerm) + return option?.searchName.includes(deburredSearchTerm) }) // Sort by whether the displayName starts with the search term to get more relevant results first ?.sort((a, b) => { - const matchA = a.displayName?.startsWith(deburredSearchTerm) - const matchB = b.displayName?.startsWith(deburredSearchTerm) + const matchA = a.searchName.startsWith(deburredSearchTerm) + const matchB = b.searchName.startsWith(deburredSearchTerm) if (matchA && !matchB) return -1 if (!matchA && matchB) return 1 @@ -183,23 +182,19 @@ export function AssigneeSelectionMenu(props: { }) { const {onSelect, menuButton, value} = props - const ref = useRef(null) - return ( - - - - - } - popover={{ - placement: 'bottom', - portal: true, - }} - /> - + + + + } + popover={{ + placement: 'bottom', + portal: true, + }} + /> ) }