Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs: toggle Decimal widget with show()/hide() per Decimal's recommended pattern

Sushmithamallesh208d37d15984
diff --git a/docs/components/ask-ai-button.tsx b/docs/components/ask-ai-button.tsx
index a17cca62a..b1d8c6e64 100644
--- a/docs/components/ask-ai-button.tsx
+++ b/docs/components/ask-ai-button.tsx
@@ -11,13 +11,19 @@ function getDecimal() {
return (window as typeof window & { Decimal?: DecimalAPI }).Decimal;
}
-function showDecimalWidget() {
+let widgetOpen = false;
+
+function toggleDecimalWidget() {
const decimal = getDecimal();
- if (decimal) {
- decimal.show();
+ if (!decimal) {
+ setTimeout(() => {
+ getDecimal()?.show();
+ widgetOpen = true;
+ }, 500);
return;
}
- setTimeout(() => getDecimal()?.show(), 500);
+ widgetOpen ? decimal.hide() : decimal.show();
+ widgetOpen = !widgetOpen;
}
function useIsMac() {
@@ -31,7 +37,7 @@ function useIsMac() {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.metaKey || e.ctrlKey) && e.key === 'i') {
e.preventDefault();
- showDecimalWidget();
+ toggleDecimalWidget();
}
};
@@ -71,7 +77,7 @@ export function SearchAndAskAI() {
)}
<button
type="button"
- onClick={showDecimalWidget}
+ onClick={toggleDecimalWidget}
className="inline-flex items-center gap-2 rounded-lg border bg-fd-secondary/50 p-1.5 ps-2.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground shrink-0"
>
Ask AI
@@ -104,7 +110,7 @@ export function SearchAndAskAIMobile() {
<button
type="button"
aria-label="Ask AI"
- onClick={showDecimalWidget}
+ onClick={toggleDecimalWidget}
className="inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 hover:bg-fd-accent hover:text-fd-accent-foreground"
>
<MessageSquare className="size-4.5" />