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.

fix(docs): toggle Decimal widget using DOM visibility detection

Sushmithamalleshda944a9a0327
diff --git a/docs/components/ask-ai-button.tsx b/docs/components/ask-ai-button.tsx
index 19a45a342..fcf822715 100644
--- a/docs/components/ask-ai-button.tsx
+++ b/docs/components/ask-ai-button.tsx
@@ -11,14 +11,25 @@ function getDecimal() {
return (window as typeof window & { Decimal?: DecimalAPI }).Decimal;
}
-function showDecimalWidget() {
+function isDecimalVisible() {
+ // Check if the push-sidebar panel is visible in the DOM
+ const panel = document.querySelector('iframe[src*="decimal"], [class*="decimal" i]');
+ if (!panel) return false;
+ const rect = panel.getBoundingClientRect();
+ return rect.width > 0 && rect.height > 0;
+}
+
+function toggleDecimalWidget() {
const decimal = getDecimal();
- if (decimal) {
- decimal.show();
+ if (!decimal) {
+ setTimeout(() => getDecimal()?.show(), 500);
return;
}
- // Widget script may not have loaded yet — retry once after a short delay
- setTimeout(() => getDecimal()?.show(), 500);
+ if (isDecimalVisible()) {
+ decimal.hide();
+ } else {
+ decimal.show();
+ }
}
function useIsMac() {
@@ -32,7 +43,7 @@ function useIsMac() {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.metaKey || e.ctrlKey) && e.key === 'i') {
e.preventDefault();
- showDecimalWidget();
+ toggleDecimalWidget();
}
};
@@ -72,7 +83,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
@@ -105,7 +116,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" />