Added a util helper to remove accent and case to improve search logic (#14533)
# [WIP] Make Local Search Non-Accent-Sensitive fixes(#14468) --- **Description:** This PR adds accent- and case-insensitive search for the **SettingsWorkspaceMembers** component’s local search. It ensures that searching for names or emails works correctly even if the user types letters without accents. **Implementation:** - Added a helper util: `removeAccentsAndCase(text: string)` - This util: - Normalizes text to NFD form - Removes diacritics (accents) - Converts text to lowercase - Replaced current `.includes(searchFilter)` logic with a normalized comparison: --- ### Video -> [Screencast from 2025-09-16 16-42-50.webm](https://github.com/user-attachments/assets/7035906c-9c5d-414d-81e5-74e53803628a) --- Opening a draft pr for initial strategy review before extending it to other components. --------- Co-authored-by: Félix Malfait <felix@twenty.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import { type TagColor } from 'twenty-ui/components';
|
||||
import { type SelectOption } from 'twenty-ui/input';
|
||||
import { MenuItemSelectTag } from 'twenty-ui/navigation';
|
||||
import { normalizeSearchText } from '~/utils/normalizeSearchText';
|
||||
|
||||
interface SelectInputProps {
|
||||
onOptionSelected: (selectedOption: SelectOption) => void;
|
||||
@@ -51,16 +52,17 @@ export const SelectInput = ({
|
||||
SelectOption | undefined
|
||||
>(defaultOption);
|
||||
|
||||
const optionsToSelect = useMemo(
|
||||
() =>
|
||||
const optionsToSelect = useMemo(() => {
|
||||
const searchTerm = normalizeSearchText(searchFilter);
|
||||
return (
|
||||
options.filter((option) => {
|
||||
return (
|
||||
option.value !== selectedOption?.value &&
|
||||
option.label.toLowerCase().includes(searchFilter.toLowerCase())
|
||||
normalizeSearchText(option.label).includes(searchTerm)
|
||||
);
|
||||
}) || [],
|
||||
[options, searchFilter, selectedOption?.value],
|
||||
);
|
||||
}) || []
|
||||
);
|
||||
}, [options, searchFilter, selectedOption?.value]);
|
||||
|
||||
const optionsInDropDown = useMemo(
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user