Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 08:15 UTC
fix(docs): toggle Decimal widget using DOM visibility detection
Checks if the widget iframe/panel is visible via getBoundingClientRect instead of tracking state manually. Calls hide() when visible, show() when not. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 19, 2026 at 16:25 UTC
da944a9a03276b7acb638c73222ec6670c40f279
1 file changed
+19
-8
docs/components/ask-ai-button.tsx
+19
-8
@@ -11,14 +11,25 @@ function getDecimal() {
11
return (window as typeof window & { Decimal?: DecimalAPI }).Decimal;
12
}
13
14
-function showDecimalWidget() {
14
+function isDecimalVisible() {
15
+ // Check if the push-sidebar panel is visible in the DOM
16
+ const panel = document.querySelector('iframe[src*="decimal"], [class*="decimal" i]');
17
+ if (!panel) return false;
18
+ const rect = panel.getBoundingClientRect();
19
+ return rect.width > 0 && rect.height > 0;
20
+}
21
+
22
+function toggleDecimalWidget() {
23
const decimal = getDecimal();
16
- if (decimal) {
17
- decimal.show();
24
+ if (!decimal) {
25
+ setTimeout(() => getDecimal()?.show(), 500);
26
return;
27
}
20
- // Widget script may not have loaded yet — retry once after a short delay
21
- setTimeout(() => getDecimal()?.show(), 500);
28
+ if (isDecimalVisible()) {
29
+ decimal.hide();
30
+ } else {
31
+ decimal.show();
32
+ }
33
}
34
35
function useIsMac() {
@@ -32,7 +43,7 @@ function useIsMac() {
43
const handleKeyDown = (e: KeyboardEvent) => {
44
if ((e.metaKey || e.ctrlKey) && e.key === 'i') {
45
e.preventDefault();
35
- showDecimalWidget();
46
+ toggleDecimalWidget();
47
}
48
};
49
@@ -72,7 +83,7 @@ export function SearchAndAskAI() {
83
)}
84
<button
85
type="button"
75
- onClick={showDecimalWidget}
86
+ onClick={toggleDecimalWidget}
87
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"
88
>
89
Ask AI
@@ -105,7 +116,7 @@ export function SearchAndAskAIMobile() {
116
<button
117
type="button"
118
aria-label="Ask AI"
108
- onClick={showDecimalWidget}
119
+ onClick={toggleDecimalWidget}
120
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"
121
>
122
<MessageSquare className="size-4.5" />