The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ui): keep create guardrail modal open on outside click (#29871)
yuneng-jiang47b383dbbfc9
diff --git a/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.test.tsx b/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.test.tsxnew file mode 100644index 00000000000..a13f12e4b42--- /dev/null+++ b/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.test.tsx@@ -0,0 +1,43 @@+import React from "react";+import { fireEvent, screen } from "@testing-library/react";+import { renderWithProviders } from "../../../tests/test-utils";+import { beforeEach, describe, expect, it, vi } from "vitest";+import AddGuardrailForm from "./add_guardrail_form";++vi.mock("@/components/networking", () => ({+ createGuardrailCall: vi.fn(),+ getGuardrailProviderSpecificParams: vi.fn().mockResolvedValue({}),+ getGuardrailUISettings: vi.fn().mockResolvedValue({}),+ modelAvailableCall: vi.fn().mockResolvedValue({ data: [] }),+}));++const renderForm = () => {+ const onClose = vi.fn();+ renderWithProviders(<AddGuardrailForm visible={true} onClose={onClose} accessToken={null} onSuccess={vi.fn()} />);+ return { onClose };+};++describe("AddGuardrailForm close behavior", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ });++ it("does not close when the user clicks outside the modal on the mask", () => {+ const { onClose } = renderForm();+ expect(screen.getByText("Create guardrail")).toBeInTheDocument();++ const wrap = document.querySelector(".ant-modal-wrap") as HTMLElement;+ expect(wrap).toBeTruthy();+ fireEvent.mouseDown(wrap);+ fireEvent.mouseUp(wrap);+ fireEvent.click(wrap);++ expect(onClose).not.toHaveBeenCalled();+ });++ it("closes when the user clicks the explicit close button", () => {+ const { onClose } = renderForm();+ fireEvent.click(screen.getByRole("button", { name: "✕" }));+ expect(onClose).toHaveBeenCalledTimes(1);+ });+});diff --git a/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.tsx b/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.tsxindex 05a65d1c9e5..41a2dd7f67c 100644--- a/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.tsx+++ b/ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.tsx@@ -1144,6 +1144,7 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, atitle={null}open={visible}onCancel={handleClose}+ maskClosable={false}footer={null}width={1000}closable={false}