diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 5f97a829..523fccc9 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -165,7 +165,7 @@ function SortableSection({ group, sectionProps }: { sectionProps: Omit & { entries: VaultEntry[]; collapsed: Record; onToggle: (type: string) => void; renamingType: string | null; renameInitialValue: string } }) { - const { attributes, setNodeRef, transform, transition, isDragging } = useSortable({ id: group.type }) + const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: group.type }) const items = sectionProps.entries.filter((e) => e.isA === group.type && !e.archived && !e.trashed) const isCollapsed = sectionProps.collapsed[group.type] ?? true const isRenaming = sectionProps.renamingType === group.type @@ -178,6 +178,7 @@ function SortableSection({ group, sectionProps }: { onSelectNote={sectionProps.onSelectNote} onCreateType={sectionProps.onCreateType} onCreateNewType={sectionProps.onCreateNewType} onContextMenu={sectionProps.onContextMenu} onToggle={() => sectionProps.onToggle(group.type)} + dragHandleProps={listeners} isRenaming={isRenaming} renameInitialValue={isRenaming ? sectionProps.renameInitialValue : undefined} onRenameSubmit={sectionProps.onRenameSubmit} diff --git a/src/components/SidebarParts.tsx b/src/components/SidebarParts.tsx index 7247784e..6b45feb7 100644 --- a/src/components/SidebarParts.tsx +++ b/src/components/SidebarParts.tsx @@ -75,6 +75,7 @@ export interface SectionContentProps { onCreateNewType?: () => void onContextMenu: (e: React.MouseEvent, type: string) => void onToggle: () => void + dragHandleProps?: Record isRenaming?: boolean renameInitialValue?: string onRenameSubmit?: (value: string) => void @@ -93,7 +94,7 @@ function resolveCreateHandler(type: string, onCreateType?: (type: string) => voi export function SectionContent({ group, items, isCollapsed, selection, onSelect, onSelectNote, - onCreateType, onCreateNewType, onContextMenu, onToggle, + onCreateType, onCreateNewType, onContextMenu, onToggle, dragHandleProps, isRenaming, renameInitialValue, onRenameSubmit, onRenameCancel, }: SectionContentProps) { const { label, type, Icon, customColor } = group @@ -113,6 +114,7 @@ export function SectionContent({ onContextMenu={(e) => onContextMenu(e, type)} onToggle={onToggle} onCreate={(e) => { e.stopPropagation(); onCreate?.() }} + dragHandleProps={dragHandleProps} isRenaming={isRenaming} renameInitialValue={renameInitialValue} onRenameSubmit={onRenameSubmit} @@ -182,11 +184,12 @@ function InlineRenameInput({ initialValue, onSubmit, onCancel }: { ) } -function SectionHeader({ label, type, Icon, sectionColor, isCollapsed, isActive, showCreate, onSelect, onContextMenu, onToggle, onCreate, isRenaming, renameInitialValue, onRenameSubmit, onRenameCancel }: { +function SectionHeader({ label, type, Icon, sectionColor, isCollapsed, isActive, showCreate, onSelect, onContextMenu, onToggle, onCreate, dragHandleProps, isRenaming, renameInitialValue, onRenameSubmit, onRenameCancel }: { label: string; type: string; Icon: ComponentType sectionColor: string; isCollapsed: boolean; isActive: boolean; showCreate: boolean onSelect: () => void; onContextMenu: (e: React.MouseEvent) => void onToggle: () => void; onCreate: (e: React.MouseEvent) => void + dragHandleProps?: Record isRenaming?: boolean; renameInitialValue?: string onRenameSubmit?: (value: string) => void; onRenameCancel?: () => void }) { @@ -194,6 +197,7 @@ function SectionHeader({ label, type, Icon, sectionColor, isCollapsed, isActive,
{ if (isRenaming) return if (isCollapsed) { onToggle(); onSelect() } diff --git a/src/test/setup.ts b/src/test/setup.ts index e2a6c7ed..5a059598 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -2,6 +2,12 @@ import '@testing-library/jest-dom/vitest' import { vi } from 'vitest' import { createElement, type ReactNode, type ComponentType } from 'react' +// Suppress undici WebSocket ERR_INVALID_ARG_TYPE in jsdom (jsdom Event ≠ Node Event) +process.on('uncaughtException', (err: NodeJS.ErrnoException) => { + if (err.code === 'ERR_INVALID_ARG_TYPE' && err.message?.includes('Event')) return + throw err +}) + // Mock scrollIntoView for jsdom (not implemented) Element.prototype.scrollIntoView = vi.fn()