fix: reverse relationships — remove header, arrow prefix, dotted underline on hover

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Test
2026-02-28 10:53:20 +01:00
parent 42b463e07a
commit 6ff3a1929a
4 changed files with 14 additions and 39 deletions

View File

@@ -485,25 +485,8 @@ Status: Active
/>
)
expect(screen.getByText(/via Belongs to/)).toBeInTheDocument()
expect(screen.getByText(/via Related to/)).toBeInTheDocument()
})
it('shows count badge for referenced-by entries', () => {
render(
<Inspector
{...defaultProps}
entry={targetEntry}
content={targetContent}
entries={[targetEntry, essayEntry, procedureEntry]}
/>
)
// 2 entries reference via Belongs to — badge appears in the Referenced by header
const allTwos = screen.getAllByText('2')
expect(allTwos.length).toBeGreaterThanOrEqual(1)
// At least one "2" is inside a badge (span with ml-1 class)
expect(allTwos.some(el => el.classList.contains('ml-1'))).toBe(true)
expect(screen.getByText(/ Belongs to/i)).toBeInTheDocument()
expect(screen.getByText(/ Related to/i)).toBeInTheDocument()
})
it('hides referenced-by section when no entries reference the current note', () => {
@@ -580,7 +563,7 @@ Status: Active
/>
)
expect(screen.getByText('On Writing Well')).toBeInTheDocument()
expect(screen.getByText(/via Topics/)).toBeInTheDocument()
expect(screen.getByText(/ Topics/i)).toBeInTheDocument()
})
it('excludes entries from backlinks when already shown in referenced-by', () => {
@@ -619,7 +602,7 @@ Status: Active
/>
)
// noteA shows in Referenced By (via Belongs to)
expect(screen.getByText(/via Belongs to/)).toBeInTheDocument()
expect(screen.getByText(/ Belongs to/i)).toBeInTheDocument()
expect(screen.getByText('On Writing Well')).toBeInTheDocument()
// But NOT in Backlinks (even though outgoingLinks matches) — section hidden
expect(screen.queryByText('Backlinks')).not.toBeInTheDocument()

View File

@@ -467,18 +467,8 @@ describe('ReferencedByPanel', () => {
expect(screen.getByText('Write Essays')).toBeInTheDocument()
expect(screen.getByText('On Writing Well')).toBeInTheDocument()
expect(screen.getByText('SEO Experiment')).toBeInTheDocument()
expect(screen.getByText(/via Belongs to/)).toBeInTheDocument()
expect(screen.getByText(/via Related to/)).toBeInTheDocument()
})
it('shows count badge when items exist', () => {
const items: ReferencedByItem[] = [
{ entry: makeEntry({ path: '/vault/a.md', title: 'A' }), viaKey: 'Has' },
{ entry: makeEntry({ path: '/vault/b.md', title: 'B' }), viaKey: 'Has' },
{ entry: makeEntry({ path: '/vault/c.md', title: 'C' }), viaKey: 'Topics' },
]
render(<ReferencedByPanel typeEntryMap={{}} items={items} onNavigate={onNavigate} />)
expect(screen.getByText('3')).toBeInTheDocument()
expect(screen.getByText(/ Belongs to/i)).toBeInTheDocument()
expect(screen.getByText(/ Related to/i)).toBeInTheDocument()
})
it('navigates when clicking a referenced-by entry', () => {

View File

@@ -413,15 +413,12 @@ export function ReferencedByPanel({ items, typeEntryMap, onNavigate }: {
if (items.length === 0) return null
return (
<div>
<h4 className="font-mono-overline mb-2 text-muted-foreground">
Referenced by <span className="ml-1" style={{ fontWeight: 400 }}>{items.length}</span>
</h4>
<div className="referenced-by-panel">
<div className="flex flex-col gap-2.5">
{grouped.map(([viaKey, groupEntries]) => (
<div key={viaKey}>
<span className="mb-1 block font-mono text-muted-foreground" style={{ fontSize: 9, fontWeight: 600, letterSpacing: '1.2px', textTransform: 'uppercase', opacity: 0.7 }}>
via {viaKey}
<span className="mb-1 block font-mono text-muted-foreground" style={{ fontSize: 9, fontWeight: 400, letterSpacing: '1.2px', textTransform: 'uppercase', opacity: 0.7 }}>
{viaKey}
</span>
<div className="flex flex-col gap-0.5">
{groupEntries.map((e) => {

View File

@@ -164,3 +164,8 @@
letter-spacing: 0.02em;
text-transform: uppercase;
}
.referenced-by-panel button:hover {
text-decoration: underline;
text-decoration-style: dotted;
}