From 63273312b2a0b89bf1c1288a1457498be1443984 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Tue, 17 Dec 2024 21:07:24 -0800 Subject: [PATCH] Fixes --- .../src/components/chat/AutoApproveMenu.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/webview-ui/src/components/chat/AutoApproveMenu.tsx b/webview-ui/src/components/chat/AutoApproveMenu.tsx index 35c24830ac..707ddcf4f5 100644 --- a/webview-ui/src/components/chat/AutoApproveMenu.tsx +++ b/webview-ui/src/components/chat/AutoApproveMenu.tsx @@ -251,13 +251,26 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => { }}> Max Requests: { - const value = parseInt((e.target as HTMLInputElement).value) + const input = e.target as HTMLInputElement + // Remove any non-numeric characters + input.value = input.value.replace(/[^0-9]/g, "") + const value = parseInt(input.value) if (!isNaN(value) && value > 0) { updateMaxRequests(value) } }} + onKeyDown={(e) => { + // Prevent non-numeric keys (except for backspace, delete, arrows) + if ( + !/^\d$/.test(e.key) && + !["Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(e.key) + ) { + e.preventDefault() + } + }} style={{ flex: 1 }} />