fix(desktop): fix right-click context menu not working on sidebar conversation items

- Skip startDragging() on right-click to prevent Tauri IPC from
  disrupting the contextmenu event on macOS
- Allow context menu to render when sidebar is collapsed
- Fix auto-dismiss effect to not self-clear contextMenu state
This commit is contained in:
程序员阿江(Relakkes) 2026-05-10 18:34:18 +08:00
parent 1aa0774cbf
commit 1749d3f392

View File

@ -45,9 +45,10 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) {
}, [fetchSessions])
useEffect(() => {
if (!contextMenu || sidebarOpen) return
setContextMenu(null)
}, [contextMenu, sidebarOpen])
if (!contextMenu) return
if (!sidebarOpen) setContextMenu(null)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sidebarOpen])
useEffect(() => {
if (!contextMenu) return
@ -116,6 +117,7 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) {
}, [])
const handleSidebarDrag = useCallback((e: React.MouseEvent) => {
if (e.button !== 0) return
if ((e.target as HTMLElement).closest('button, input, textarea, select, a, [role="button"]')) return
startDraggingRef.current?.()
}, [])
@ -379,7 +381,7 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) {
</div>
)}
{contextMenu && sidebarOpen && (
{contextMenu && (
<div
className="fixed z-50 min-w-[140px] rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] py-1"
style={{ left: contextMenu.x, top: contextMenu.y, boxShadow: 'var(--shadow-dropdown)' }}