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:
@@ -171,4 +171,21 @@ describe('useNoteSearch', () => {
|
||||
})
|
||||
expect(preventDefaultSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('resolves custom type color from Type entries', () => {
|
||||
const withTypes: VaultEntry[] = [
|
||||
makeEntry({ path: '/vault/t/recipe.md', title: 'Recipe', isA: 'Type', color: 'orange', icon: 'cooking-pot' }),
|
||||
makeEntry({ path: '/vault/pasta.md', title: 'Pasta', isA: 'Recipe', modifiedAt: 1700000010 }),
|
||||
makeEntry({ path: '/vault/proj.md', title: 'My Project', isA: 'Project', modifiedAt: 1700000009 }),
|
||||
]
|
||||
const { result } = renderHook(() => useNoteSearch(withTypes, ''))
|
||||
const pasta = result.current.results.find(r => r.title === 'Pasta')
|
||||
expect(pasta?.noteType).toBe('Recipe')
|
||||
expect(pasta?.typeColor).toBe('var(--accent-orange)')
|
||||
expect(pasta?.TypeIcon).toBeDefined()
|
||||
// Built-in type still works
|
||||
const project = result.current.results.find(r => r.title === 'My Project')
|
||||
expect(project?.typeColor).toBe('var(--accent-red)')
|
||||
expect(project?.TypeIcon).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user