From 321f918dca4702c4ab4dac4302c9dcbfc0a3b06e Mon Sep 17 00:00:00 2001 From: benya Date: Sun, 8 Mar 2026 00:44:57 +0300 Subject: [PATCH] fix(web): keep chat context menu within viewport - adjust right-click menu coordinates to avoid clipping near screen edges --- web/src/components/ChatList.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/src/components/ChatList.tsx b/web/src/components/ChatList.tsx index 3399194..9b92aba 100644 --- a/web/src/components/ChatList.tsx +++ b/web/src/components/ChatList.tsx @@ -84,8 +84,9 @@ export function ChatList() { onClick={() => setActiveChatId(chat.id)} onContextMenu={(e) => { e.preventDefault(); + const safePos = getSafeContextPosition(e.clientX, e.clientY); setCtxChatId(chat.id); - setCtxPos({ x: e.clientX, y: e.clientY }); + setCtxPos(safePos); }} >
@@ -155,3 +156,11 @@ export function ChatList() { ); } + function getSafeContextPosition(x: number, y: number): { x: number; y: number } { + const menuWidth = 176; + const menuHeight = 56; + const pad = 8; + const safeX = Math.min(Math.max(pad, x), window.innerWidth - menuWidth - pad); + const safeY = Math.min(Math.max(pad, y), window.innerHeight - menuHeight - pad); + return { x: safeX, y: safeY }; + }