Describe the bug
window.$chatwoot creating cynchronously in chatwootSDK.run() - with all methods and hasLoaded: false, app may count that SDK is ready and start to use his methods like toggleBubbleVisiblity (entrypoints/sdk.js#87-102). However, SDK may be not ready, because DOM of bubble creating way later than this - inside IFRameHelper.onLoad (sdk/IFrameHelper.js#156-193) which is triggered by postMessage in onLoad. Toggle visiblity never checks querySelector result. In result we have two scenarios of error (had been spotted inside real application):
- user returned back on the page with this sdk, tag of the script is inside DOM, $chatwoot here, but iframe is not ready -> .woot-bubble-holder === null
- user exiting the page earlier than widget loaded -> addClasses fails with fatal error (can't access property 'e', classList is null)
To Reproduce
- create app that uses sdk and count on $chatwoot
- try to leave page just when you visited it in browser
Expected behavior
No response
Environment
Linux VM
Cloud Provider
None
Platform
Browser
Operating system
Windows
Browser and version
Zen Browser 1.21.15b
Docker (if applicable)
No response
Additional context
No response
Describe the bug
window.$chatwoot creating cynchronously in chatwootSDK.run() - with all methods and hasLoaded: false, app may count that SDK is ready and start to use his methods like toggleBubbleVisiblity (entrypoints/sdk.js#87-102). However, SDK may be not ready, because DOM of bubble creating way later than this - inside IFRameHelper.onLoad (sdk/IFrameHelper.js#156-193) which is triggered by postMessage in onLoad. Toggle visiblity never checks querySelector result. In result we have two scenarios of error (had been spotted inside real application):
To Reproduce
Expected behavior
No response
Environment
Linux VM
Cloud Provider
None
Platform
Browser
Operating system
Windows
Browser and version
Zen Browser 1.21.15b
Docker (if applicable)
No response
Additional context
No response