feat(dashboard): trigger key validation on Enter in AddApiKeyModal (#10995) (#11056)

5 — onKeyDown Enter no input de chave da AddApiKeyModal dispara a validação. TDD. Fecha #10995.
This commit is contained in:
Rouzbeh†
2026-08-22 03:36:18 +03:30
committed by GitHub
parent 9b801b7e09
commit 7e48be8061
2 changed files with 32 additions and 0 deletions

View File

@@ -757,6 +757,12 @@ export default function AddApiKeyModal({
type="password"
value={formData.apiKey}
onChange={(e) => setFormData({ ...formData, apiKey: e.target.value })}
onKeyDown={(e) => {
if (e.key === "Enter" && !validating && !saving) {
e.preventDefault();
handleValidate();
}
}}
className="flex-1"
placeholder={apiCredentialPlaceholder}
hint={apiCredentialHint}

View File

@@ -0,0 +1,26 @@
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
describe("AddApiKeyModal Enter key submit (#10995)", () => {
it("AddApiKeyModal attaches onKeyDown Enter handler to the API Key input", () => {
const modalPath = path.resolve(
process.cwd(),
"src/app/(dashboard)/dashboard/providers/[id]/components/modals/AddApiKeyModal.tsx"
);
const content = fs.readFileSync(modalPath, "utf8");
assert.ok(
content.includes("onKeyDown"),
"AddApiKeyModal must contain onKeyDown event handler for Enter key validation"
);
assert.ok(
content.includes('e.key === "Enter"'),
"onKeyDown handler must check for Enter key press"
);
assert.ok(
content.includes("handleValidate()"),
"Enter key press must invoke handleValidate()"
);
});
});