mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-01 08:59:46 +02:00
fix: guard Chatwoot bubble toggle until holder is in the DOM (#485)
ChatwootWidget's visibility effect took the synchronous fast path whenever
`window.$chatwoot` was truthy. But the SDK assigns `$chatwoot` (with
`toggleBubbleVisibility`) synchronously in run(), while `.woot--bubble-holder`
is only appended later, after the widget iframe finishes loading. Calling
`toggleBubbleVisibility("show")` in that gap makes the SDK dereference
`null.classList` — an intermittent crash on navigating to /workflow that
surfaces via the React error boundary (follow-up to #483).
Gate the immediate-apply path on the bubble holder actually being in the DOM;
when it's absent, fall through to the existing `chatwoot:ready` listener, which
the SDK fires only after the holder is created.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a616b7ff98
commit
a850d18767
1 changed files with 6 additions and 3 deletions
|
|
@ -99,9 +99,12 @@ export default function ChatwootWidget() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// The SDK may not be ready on first navigation; apply once it fires
|
// Apply immediately only once the bubble holder is actually in the DOM.
|
||||||
// `chatwoot:ready`, otherwise apply immediately.
|
// `window.$chatwoot` exists synchronously after run(), but `.woot--bubble-holder`
|
||||||
if (window.$chatwoot) {
|
// is appended later when the widget iframe loads, and toggleBubbleVisibility()
|
||||||
|
// dereferences it with no null check. When it's absent, fall through to
|
||||||
|
// `chatwoot:ready`, which the SDK fires once the holder exists.
|
||||||
|
if (window.$chatwoot && document.querySelector(".woot--bubble-holder")) {
|
||||||
applyVisibility();
|
applyVisibility();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue