fix(typebot-js): 🐛 Open iframe on proactive message click
This commit is contained in:
5
.github/workflows/publish-lib-to-npm.yml
vendored
5
.github/workflows/publish-lib-to-npm.yml
vendored
@ -1,9 +1,8 @@
|
|||||||
name: Publish package to NPM
|
name: Publish package to NPM
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
create:
|
||||||
tags:
|
tags: ['js-lib-v*']
|
||||||
- 'js-lib-v*.*.*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "typebot-js",
|
"name": "typebot-js",
|
||||||
"version": "2.2.8",
|
"version": "2.2.9",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"unpkg": "dist/index.umd.min.js",
|
"unpkg": "dist/index.umd.min.js",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
|
@ -77,8 +77,9 @@ const onProactiveMessageClick = (
|
|||||||
bubble: HTMLDivElement,
|
bubble: HTMLDivElement,
|
||||||
iframe: HTMLIFrameElement
|
iframe: HTMLIFrameElement
|
||||||
): void => {
|
): void => {
|
||||||
loadTypebotIfFirstOpen(iframe)
|
iframe.style.display === 'none'
|
||||||
bubble.classList.add('iframe-opened')
|
? openIframe(bubble, iframe)
|
||||||
|
: closeIframe(bubble, iframe)
|
||||||
bubble.classList.remove('message-opened')
|
bubble.classList.remove('message-opened')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,3 +75,22 @@ it('show after the corresponding delay', async () => {
|
|||||||
await new Promise((r) => setTimeout(r, 1000))
|
await new Promise((r) => setTimeout(r, 1000))
|
||||||
expect(bubble.classList.contains('message-opened')).toBe(true)
|
expect(bubble.classList.contains('message-opened')).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('show the chat on click', async () => {
|
||||||
|
expect.assertions(3)
|
||||||
|
Typebot.initBubble({
|
||||||
|
proactiveMessage: {
|
||||||
|
textContent: 'Hi click here!',
|
||||||
|
delay: 1000,
|
||||||
|
},
|
||||||
|
url: 'https://typebot.io/typebot-id',
|
||||||
|
})
|
||||||
|
const bubble = document.querySelector('#typebot-bubble') as HTMLDivElement
|
||||||
|
const iframe = document.querySelector('.typebot-iframe') as HTMLIFrameElement
|
||||||
|
expect(bubble.classList.contains('message-opened')).toBe(false)
|
||||||
|
await new Promise((r) => setTimeout(r, 1000))
|
||||||
|
expect(bubble.classList.contains('message-opened')).toBe(true)
|
||||||
|
const message = document.querySelector('.proactive-message') as HTMLDivElement
|
||||||
|
message.click()
|
||||||
|
expect(iframe.style.display).not.toBe('none')
|
||||||
|
})
|
||||||
|
Reference in New Issue
Block a user