From a4842e2cd4d6d0756cf97069720f7ff336fe6a0a Mon Sep 17 00:00:00 2001 From: Oleg Proskurin Date: Fri, 24 Oct 2025 23:24:38 +0700 Subject: [PATCH] fix: focus --- .../components/docs/blocks/InteractiveAPIWidget.tsx | 7 +++++-- .../components/shared/ApiKeyWidget/apikey-context.tsx | 11 +++++++---- .../components/shared/ApiKeyWidget/apikey-widget.tsx | 6 ++++-- apps/landing/src/lib/apikey/types.ts | 4 ++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/apps/landing/src/components/docs/blocks/InteractiveAPIWidget.tsx b/apps/landing/src/components/docs/blocks/InteractiveAPIWidget.tsx index 8b91a4d..195b913 100644 --- a/apps/landing/src/components/docs/blocks/InteractiveAPIWidget.tsx +++ b/apps/landing/src/components/docs/blocks/InteractiveAPIWidget.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useApiKey } from '@/components/shared/ApiKeyWidget/apikey-context'; /** * Interactive API Widget - Production Version * @@ -60,6 +61,8 @@ export const InteractiveAPIWidget = ({ const [isExpanded, setIsExpanded] = useState(false); const [paramValues, setParamValues] = useState>({}); + const {apiKeyValidated, focus} = useApiKey() + // Load API key from localStorage and listen for changes useEffect(() => { const loadApiKey = () => { @@ -266,7 +269,7 @@ func main() { // Expand API key input in navigation const expandApiKey = () => { - window.dispatchEvent(new CustomEvent('expandApiKeyInput')); + focus(); }; const isSuccess = response && response.success === true; @@ -336,7 +339,7 @@ func main() { onClick={expandApiKey} className="text-sm text-gray-400 hover:text-white underline-offset-4 hover:underline transition-colors" > - {apiKey ? 'API Key Set' : 'Enter API Key'} + {apiKeyValidated ? 'API Key Set' : 'Enter API Key'}