🐛 (js) Fix popup closing on bot click
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
1
packages/js/src/env.d.ts
vendored
1
packages/js/src/env.d.ts
vendored
@@ -4,6 +4,7 @@ declare module 'solid-js' {
|
|||||||
namespace JSX {
|
namespace JSX {
|
||||||
interface CustomEvents {
|
interface CustomEvents {
|
||||||
click: MouseEvent
|
click: MouseEvent
|
||||||
|
pointerdown: PointerEvent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ export type PopupProps = BotProps &
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Popup = (props: PopupProps) => {
|
export const Popup = (props: PopupProps) => {
|
||||||
let botContainer: HTMLDivElement | undefined
|
|
||||||
|
|
||||||
const [popupProps, botProps] = splitProps(props, [
|
const [popupProps, botProps] = splitProps(props, [
|
||||||
'onOpen',
|
'onOpen',
|
||||||
'onClose',
|
'onClose',
|
||||||
@@ -92,7 +90,6 @@ export const Popup = (props: PopupProps) => {
|
|||||||
popupProps.onOpen?.()
|
popupProps.onOpen?.()
|
||||||
document.body.style.overflow = 'hidden'
|
document.body.style.overflow = 'hidden'
|
||||||
document.addEventListener('pointerdown', closeBot)
|
document.addEventListener('pointerdown', closeBot)
|
||||||
botContainer?.addEventListener('pointerdown', stopPropagation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const closeBot = () => {
|
const closeBot = () => {
|
||||||
@@ -100,7 +97,6 @@ export const Popup = (props: PopupProps) => {
|
|||||||
popupProps.onClose?.()
|
popupProps.onClose?.()
|
||||||
document.body.style.overflow = 'auto'
|
document.body.style.overflow = 'auto'
|
||||||
document.removeEventListener('pointerdown', closeBot)
|
document.removeEventListener('pointerdown', closeBot)
|
||||||
botContainer?.removeEventListener('pointerdown', stopPropagation)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleBot = () => {
|
const toggleBot = () => {
|
||||||
@@ -126,7 +122,7 @@ export const Popup = (props: PopupProps) => {
|
|||||||
'background-color':
|
'background-color':
|
||||||
props.theme?.backgroundColor ?? 'transparent',
|
props.theme?.backgroundColor ?? 'transparent',
|
||||||
}}
|
}}
|
||||||
ref={botContainer}
|
on:pointerdown={stopPropagation}
|
||||||
>
|
>
|
||||||
<Bot {...botProps} prefilledVariables={prefilledVariables()} />
|
<Bot {...botProps} prefilledVariables={prefilledVariables()} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user