fix(web): truncate long parent paths in skill file-tree search results

This commit is contained in:
yyh
2026-02-24 23:50:28 +08:00
parent 2e0661aa90
commit f13f5a8882
2 changed files with 23 additions and 2 deletions

View File

@ -83,6 +83,23 @@ describe('SearchResultList', () => {
expect(screen.queryByText('readme.md')).not.toBeInTheDocument()
expect(screen.queryByRole('button')).not.toBeInTheDocument()
})
it('should apply truncation semantics to long parent paths', () => {
const longParentPath = 'docx/scripts/office/schemas/ISO-IEC29500-4_2016/very/deep/path'
const treeChildren = [
createNode({
id: 'file-1',
name: 'sample.md',
path: `/${longParentPath}/sample.md`,
}),
]
render(<SearchResultList searchTerm="sample" treeChildren={treeChildren} />)
const parentPath = screen.getByText(longParentPath)
expect(parentPath).toHaveClass('truncate', 'text-right')
expect(parentPath).toHaveAttribute('title', longParentPath)
})
})
// File and folder actions should dispatch the correct store operations.

View File

@ -53,7 +53,8 @@ const SearchResultRow = ({ node, parentPath, treeChildren }: SearchResultRowProp
role="button"
tabIndex={0}
className={cn(
'flex h-6 w-full cursor-pointer items-center rounded-md px-2',
'flex h-6 w-full items-center gap-2 overflow-hidden rounded-md px-2',
'cursor-pointer',
'hover:bg-state-base-hover',
isActive && 'bg-state-base-active',
)}
@ -84,7 +85,10 @@ const SearchResultRow = ({ node, parentPath, treeChildren }: SearchResultRowProp
</span>
</div>
{parentPath && (
<span className="shrink-0 text-text-tertiary system-xs-regular">
<span
title={parentPath}
className="block min-w-0 max-w-[45%] truncate text-right text-text-tertiary system-xs-regular"
>
{parentPath}
</span>
)}