Skip to content

Commit

Permalink
fix(core): tag inline editor filter should ignore case (#8936)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Dec 12, 2024
1 parent 91089ff commit ae2d0c3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/frontend/core/src/components/tags/tags-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,28 @@ export const TagsEditor = ({
}: TagsEditorProps) => {
const t = useI18n();
const [inputValue, setInputValue] = useState('');
const filteredTags = tags.filter(tag => tag.value.includes(inputValue));

const trimmedInputValue = inputValue.trim();

const filteredTags = tags.filter(tag =>
tag.value.toLowerCase().includes(trimmedInputValue.toLowerCase())
);
const inputRef = useRef<HTMLInputElement>(null);

const exactMatch = filteredTags.find(tag => tag.value === inputValue);
const showCreateTag = !exactMatch && inputValue.trim();
const exactMatch = filteredTags.find(tag => tag.value === trimmedInputValue);
const showCreateTag = !exactMatch && trimmedInputValue;

// tag option candidates to show in the tag dropdown
const tagOptions: TagOption[] = useMemo(() => {
if (showCreateTag) {
return [{ create: true, value: inputValue } as const, ...filteredTags];
return [
{ create: true, value: trimmedInputValue } as const,
...filteredTags,
];
} else {
return filteredTags;
}
}, [filteredTags, inputValue, showCreateTag]);
}, [filteredTags, showCreateTag, trimmedInputValue]);

const [focusedIndex, setFocusedIndex] = useState<number>(-1);
const [focusedInlineIndex, setFocusedInlineIndex] = useState<number>(
Expand Down

0 comments on commit ae2d0c3

Please sign in to comment.