|
1 | 1 | import { CheckIcon, ChevronDownIcon } from "lucide-react"; |
2 | | -import { useMemo, useState } from "react"; |
| 2 | +import { useState } from "react"; |
3 | 3 |
|
4 | 4 | import { |
5 | 5 | CODE_BLOCK_LANGUAGES, |
@@ -36,20 +36,15 @@ export function ComposerCodeBlockLanguagePicker(props: { |
36 | 36 | }) { |
37 | 37 | const [query, setQuery] = useState(""); |
38 | 38 | const current = codeLanguageEntry(props.language)?.id ?? props.language; |
39 | | - const items = useMemo<CodeBlockLanguage[]>( |
40 | | - () => |
41 | | - CODE_BLOCK_LANGUAGES.some((entry) => entry.id === current) |
42 | | - ? [...CODE_BLOCK_LANGUAGES] |
43 | | - : [{ id: current, label: current }, ...CODE_BLOCK_LANGUAGES], |
44 | | - [current], |
45 | | - ); |
46 | | - const filteredItems = useMemo(() => { |
47 | | - const needle = query.trim().toLowerCase(); |
48 | | - if (!needle) return items; |
49 | | - return items.filter( |
50 | | - (entry) => entry.label.toLowerCase().includes(needle) || entry.id.includes(needle), |
51 | | - ); |
52 | | - }, [items, query]); |
| 39 | + const items: CodeBlockLanguage[] = CODE_BLOCK_LANGUAGES.some((entry) => entry.id === current) |
| 40 | + ? [...CODE_BLOCK_LANGUAGES] |
| 41 | + : [{ id: current, label: current }, ...CODE_BLOCK_LANGUAGES]; |
| 42 | + const needle = query.trim().toLowerCase(); |
| 43 | + const filteredItems = needle |
| 44 | + ? items.filter( |
| 45 | + (entry) => entry.label.toLowerCase().includes(needle) || entry.id.includes(needle), |
| 46 | + ) |
| 47 | + : items; |
53 | 48 | const selected = items.find((entry) => entry.id === current) ?? null; |
54 | 49 |
|
55 | 50 | return ( |
|
0 commit comments