fix: resolve custom type color and icon in all autocomplete contexts (#84)
* fix: resolve custom type color and icon in all autocomplete contexts Custom types (e.g., Evergreen, Recipe) appeared grey in wikilink [[, @-mention, Cmd+P, and search autocompletes because getTypeColor() was called without the custom color key from the Type document. Root causes: - Editor.tsx: getTypeColor(group) missing typeEntryMap[group]?.color - useNoteSearch.ts: getTypeColor(e.isA) missing custom color lookup - SearchPanel.tsx: type badge had no color styling at all Fixes: - Extract buildTypeEntryMap to shared utility in typeColors.ts - Pass custom color key in all autocomplete code paths - Add type icon (Phosphor) to the left of each result in NoteSearchList - Add TypeIcon to WikilinkSuggestionItem and NoteAutocomplete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add design file for autocomplete type color fix Shows the fixed state: type icon on the left, colored type badge on the right, untyped notes neutral grey with no icon. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState, useRef, useCallback, useMemo, useEffect } from 'react'
|
||||
import { useState, useRef, useCallback, useMemo, useEffect, type ComponentType, type SVGAttributes } from 'react'
|
||||
import type { VaultEntry } from '../types'
|
||||
import { getTypeColor } from '../utils/typeColors'
|
||||
import { getTypeIcon } from './NoteItem'
|
||||
import './WikilinkSuggestionMenu.css'
|
||||
|
||||
const MIN_QUERY_LENGTH = 2
|
||||
@@ -22,6 +23,7 @@ interface MatchedEntry {
|
||||
title: string
|
||||
noteType?: string
|
||||
typeColor?: string
|
||||
TypeIcon?: ComponentType<SVGAttributes<SVGSVGElement>>
|
||||
}
|
||||
|
||||
function matchEntries(entries: VaultEntry[], typeEntryMap: Record<string, VaultEntry>, query: string): MatchedEntry[] {
|
||||
@@ -39,6 +41,7 @@ function matchEntries(entries: VaultEntry[], typeEntryMap: Record<string, VaultE
|
||||
title: e.title,
|
||||
noteType,
|
||||
typeColor: noteType ? getTypeColor(isA, te?.color) : undefined,
|
||||
TypeIcon: noteType ? getTypeIcon(isA, te?.icon) : undefined,
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -135,7 +138,10 @@ export function NoteAutocomplete({ entries, typeEntryMap, value, onChange, onSel
|
||||
onClick={() => handleSelect(item.title)}
|
||||
onMouseEnter={() => setSelectedIndex(index)}
|
||||
>
|
||||
<span className="wikilink-menu__title">{item.title}</span>
|
||||
<span className="wikilink-menu__title" style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
{item.TypeIcon && <item.TypeIcon width={14} height={14} style={{ color: item.typeColor, flexShrink: 0 }} />}
|
||||
{item.title}
|
||||
</span>
|
||||
{item.noteType && (
|
||||
<span className="wikilink-menu__type" style={{ color: item.typeColor }}>
|
||||
{item.noteType}
|
||||
|
||||
Reference in New Issue
Block a user