mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
fix(webui): prevent clipping of long text overlay and date picker in cards (#490)
* fix(webui): prevent clipping of long text overlay and date picker in cards * docs: update DeepWiki badge url in README and README_CN * fix(webui): preserve expanded overlay height and textarea style in LongTextField * fix(webui): add bottom padding to file list to prevent screen clipping of expanded fields * fix(webui): expand directly into edit mode on single click for LongTextField * fix(webui): prevent file selection when interacting with metadata fields in cards and list rows
This commit is contained in:
@@ -476,4 +476,102 @@ describe('FileCard', () => {
|
||||
expect(matchedDuration).toBeTruthy()
|
||||
expect(matchedDuration.textContent).toBe('01:05 - 02:05')
|
||||
})
|
||||
|
||||
it('renders custom fields and allows expanding longText in FileCard', () => {
|
||||
const itemWithFields: AssetInfo = {
|
||||
...fileItem,
|
||||
fieldValues: [
|
||||
{
|
||||
fieldId: 'field_long_text',
|
||||
value: 'Line 1\nLine 2\nLine 3\nLine 4',
|
||||
},
|
||||
],
|
||||
} as AssetInfo
|
||||
|
||||
const fields = [
|
||||
{
|
||||
id: 'field_long_text',
|
||||
name: 'Notes',
|
||||
scope: 'project',
|
||||
readOnly: false,
|
||||
visible: true,
|
||||
description: '',
|
||||
config: {
|
||||
type: 'longText' as const,
|
||||
name: 'Notes',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
renderComponent({ item: itemWithFields, fields })
|
||||
|
||||
expect(screen.getByText('Notes')).toBeTruthy()
|
||||
const collapsed = screen.getByTestId('long-text-placeholder')
|
||||
expect(collapsed).toBeTruthy()
|
||||
|
||||
// Expanding directly enters editing mode on single click
|
||||
fireEvent.click(collapsed)
|
||||
const textarea = screen.getByRole('textbox') as HTMLTextAreaElement
|
||||
expect(textarea).toBeTruthy()
|
||||
expect(textarea.value).toContain('Line 1')
|
||||
expect(textarea.value).toContain('Line 4')
|
||||
})
|
||||
|
||||
it('does not trigger onSelect when clicking a single line text field or number field to edit', () => {
|
||||
const onSelect = vi.fn()
|
||||
const itemWithFields: AssetInfo = {
|
||||
...fileItem,
|
||||
fieldValues: [
|
||||
{
|
||||
fieldId: 'field_text',
|
||||
value: 'Single line text',
|
||||
},
|
||||
{
|
||||
fieldId: 'field_number',
|
||||
value: 42,
|
||||
},
|
||||
],
|
||||
} as AssetInfo
|
||||
|
||||
const fields = [
|
||||
{
|
||||
id: 'field_text',
|
||||
name: 'Title',
|
||||
scope: 'project',
|
||||
readOnly: false,
|
||||
visible: true,
|
||||
description: '',
|
||||
config: {
|
||||
type: 'text' as const,
|
||||
name: 'Title',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'field_number',
|
||||
name: 'Score',
|
||||
scope: 'project',
|
||||
readOnly: false,
|
||||
visible: true,
|
||||
description: '',
|
||||
config: {
|
||||
type: 'number' as const,
|
||||
name: 'Score',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
renderComponent({ item: itemWithFields, fields, onSelect })
|
||||
|
||||
// Click single line text field
|
||||
const textField = screen.getByText('Single line text')
|
||||
fireEvent.click(textField)
|
||||
expect(screen.getByDisplayValue('Single line text')).toBeTruthy()
|
||||
expect(onSelect).not.toHaveBeenCalled()
|
||||
|
||||
// Click number field
|
||||
const numberField = screen.getByText('42')
|
||||
fireEvent.click(numberField)
|
||||
expect(screen.getByDisplayValue('42')).toBeTruthy()
|
||||
expect(onSelect).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -617,7 +617,11 @@ export function FileCard({
|
||||
)}
|
||||
</div>
|
||||
{fields && fields.length > 0 && (
|
||||
<div className="space-y-2 border-t p-1 pt-3 mx-2">
|
||||
<div
|
||||
className="space-y-2 border-t p-1 pt-3 mx-2"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{fields.map((field) => {
|
||||
const Icon = field.config?.type
|
||||
? FIELD_TYPE_ICONS[field.config.type as FieldType]
|
||||
|
||||
@@ -147,4 +147,40 @@ describe('FileListItem', () => {
|
||||
expect(failedLabel).toBeTruthy()
|
||||
expect(failedLabel.textContent).toMatch(/Processing failed|处理失败/i)
|
||||
})
|
||||
|
||||
it('does not trigger onSelect when clicking a custom field in list view', () => {
|
||||
const onSelect = vi.fn()
|
||||
const itemWithFields: AssetInfo = {
|
||||
...mockItem,
|
||||
fieldValues: [
|
||||
{
|
||||
fieldId: 'field_text',
|
||||
value: 'List text value',
|
||||
},
|
||||
],
|
||||
} as AssetInfo
|
||||
|
||||
const fields = [
|
||||
{
|
||||
id: 'field_text',
|
||||
name: 'Custom Column',
|
||||
scope: 'project',
|
||||
readOnly: false,
|
||||
visible: true,
|
||||
description: '',
|
||||
config: {
|
||||
type: 'text' as const,
|
||||
name: 'Custom Column',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
renderComponent({ item: itemWithFields, fields, onSelect })
|
||||
|
||||
const textField = screen.getByText('List text value')
|
||||
fireEvent.click(textField)
|
||||
|
||||
expect(screen.getByDisplayValue('List text value')).toBeTruthy()
|
||||
expect(onSelect).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -328,6 +328,8 @@ export function FileListItem({
|
||||
fields.map((field) => (
|
||||
<div
|
||||
key={field.id}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
className="px-4 py-2 truncate border-r shrink-0 flex items-center"
|
||||
style={{
|
||||
width: columnSizing?.[field.id!] || 150,
|
||||
|
||||
@@ -182,6 +182,7 @@ export function FileBrowserGridView({
|
||||
[rows],
|
||||
),
|
||||
overscan: 5,
|
||||
paddingEnd: 240,
|
||||
})
|
||||
|
||||
const virtualItems = rowVirtualizer.getVirtualItems()
|
||||
|
||||
@@ -332,6 +332,7 @@ export function FileBrowserListView({
|
||||
[items, folders, files],
|
||||
),
|
||||
overscan: 10,
|
||||
paddingEnd: 240,
|
||||
})
|
||||
|
||||
const virtualItems = rowVirtualizer.getVirtualItems()
|
||||
|
||||
Reference in New Issue
Block a user