Skip to content

Commit

Permalink
fix(typebot-js): 🐛 Open iframe on proactive message click
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 6, 2022
1 parent f1f5299 commit 2e4d9d5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/publish-lib-to-npm.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Publish package to NPM

on:
push:
tags:
- 'js-lib-v*.*.*'
create:
tags: ['js-lib-v*']

jobs:
publish:
Expand Down
2 changes: 1 addition & 1 deletion packages/typebot-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typebot-js",
"version": "2.2.8",
"version": "2.2.9",
"main": "dist/index.js",
"unpkg": "dist/index.umd.min.js",
"license": "AGPL-3.0-or-later",
Expand Down
5 changes: 3 additions & 2 deletions packages/typebot-js/src/embedTypes/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ const onProactiveMessageClick = (
bubble: HTMLDivElement,
iframe: HTMLIFrameElement
): void => {
loadTypebotIfFirstOpen(iframe)
bubble.classList.add('iframe-opened')
iframe.style.display === 'none'
? openIframe(bubble, iframe)
: closeIframe(bubble, iframe)
bubble.classList.remove('message-opened')
}

Expand Down
19 changes: 19 additions & 0 deletions packages/typebot-js/tests/chat/proactiveMessage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,22 @@ it('show after the corresponding delay', async () => {
await new Promise((r) => setTimeout(r, 1000))
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')
})

4 comments on commit 2e4d9d5

@vercel
Copy link

@vercel vercel bot commented on 2e4d9d5 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs.typebot.io
docs-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2e4d9d5 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

an.nigerias.io
bt.id8rs.com
bot.aws.bj
bot.lalmon.com
ar.nigerias.io
vhpage.cr8.ai
8jours.top
apo.nigerias.io
sat.cr8.ai
am.nigerias.io
apr.nigerias.io
aso.nigerias.io
games.klujo.com
clo.closeer.work
sakuranembro.it
chat.sureb4.com
bot.upfunnel.art
eventhub.com.au
bot.piccinato.co
faqs.nigerias.io
voicehelp.cr8.ai
feedback.ofx.one
stan.vselise.com
k1.kandabrand.com
app.chatforms.net
bot.maitempah.com
bot.agfunnel.tech
ov2.wpwakanda.com
gentleman-shop.fr
ov1.wpwakanda.com
ov3.wpwakanda.com
goalsettingbot.com
this-is-a-test.com
bot.eventhub.com.au
zap.techadviser.in
forms.webisharp.com
carsalesenquiry.com
order.maitempah.com
typebot.stillio.com
bot.ansuraniphone.my
bot.cotemeuplano.com
chat.hayurihijab.com
get.freebotoffer.xyz
bbutton.wpwakanda.com
bot.meuesocial.com.br
abutton.wpwakanda.com
bot.incusservices.com
cdd.searchcube.com.sg
chat.missarkansas.org
sbutton.wpwakanda.com
bbutton.wpwwakanda.com
apply.ansuraniphone.my
c23111azqw.nigerias.io
felipewelington.com.br
info.clickasuransi.com
form.searchcube.com.sg
gcase.barrettamario.it
kodawariab736.skeep.it
report.gratirabbit.com
resume.gratirabbit.com
83242573.actualizar.xyz
view.onlinebotdemo.xyz
bot.upgradesolutions.eu
mainmenu.diddancing.com
subfooter.wpwakanda.com
form.sergiolimajr.com.br
91181264.your-access.one
hunterbot.saleshunter.ai
aibot.angrybranding.co.uk
type.opaulovieira.com.br
bot.cabinrentalagency.com
boyfriend-breakup.riku.ai
type.dericsoncalari.com.br
designguide.techyscouts.com
piazzatorre.barrettamario.it
presente.empresarias.com.mx
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
bot.comercializadoraomicron.com
bookings.littlepartymonkeys.com
personal-trainer.barrettamario.it
viewer-v2-alpha-typebot-io.vercel.app
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2e4d9d5 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 2e4d9d5 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.