Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(ui): commit API key draft on click-outside instead of discarding it (#1039)

Gabriel Stein173456b07b43
diff --git a/src/components/ui/ApiKeyInput.tsx b/src/components/ui/ApiKeyInput.tsx
index 3daf66d7b..637caa0f7 100644
--- a/src/components/ui/ApiKeyInput.tsx
+++ b/src/components/ui/ApiKeyInput.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useRef } from "react";
+import React, { useState, useEffect, useRef, useCallback } from "react";
import { useTranslation } from "react-i18next";
import { Check, X, KeyRound } from "lucide-react";
import { Input } from "./input";
@@ -54,14 +54,14 @@ export default function ApiKeyInput({
setIsEditing(true);
};
- const save = () => {
+ const save = useCallback(() => {
try {
setApiKey(draft.trim());
} catch (err) {
logger.warn("Failed to save API key", { error: (err as Error).message }, "settings");
}
setIsEditing(false);
- };
+ }, [draft, setApiKey]);
const cancel = () => {
setDraft("");
@@ -79,15 +79,17 @@ export default function ApiKeyInput({
}
};
+ // Commit the draft instead of discarding it — users paste a key and click
+ // the next field expecting it to stick (Escape or ✕ still cancels).
useEffect(() => {
if (!isEditing) return;
const handleClickOutside = (e: MouseEvent) => {
if (containerRef.current?.contains(e.target as Node)) return;
- cancel();
+ save();
};
document.addEventListener("mousedown", handleClickOutside);
return () => document.removeEventListener("mousedown", handleClickOutside);
- }, [isEditing]);
+ }, [isEditing, save]);
return (
<div className={className}>