Giter Site home page Giter Site logo

Popover 只展示了一次 about chatui HOT 8 CLOSED

alibaba avatar alibaba commented on June 25, 2024
Popover 只展示了一次

from chatui.

Comments (8)

bacchusjaa avatar bacchusjaa commented on June 25, 2024

我也遇到类似的问题 不过我的是表情组件第一次渲染之后可以弹出来 第二次点击就弹不出来了

from chatui.

akai avatar akai commented on June 25, 2024

有 demo 吗?

from chatui.

bacchusjaa avatar bacchusjaa commented on June 25, 2024

有 demo 吗?
var bot = new ChatSDK({
config: {
navbar: {
title: '智能助理'
},
robot: {
avatar: '//gw.alicdn.com/tfs/TB1U7FBiAT2gK0jSZPcXXcKkpXa-108-108.jpg'
},
toolbar: [
{
type: 'image',
icon: 'image',
title: '相册',
},
{
type: 'emoji',
icon: 'smile',
title: '表情',
render:
<Picker
style={{ width: '100%' }}
key={Math.random()*100}
/>
},
],
messages: [
{
type: 'text',
content: {
text: '智能助理为您服务,请问有什么可以帮您?'
}
}
]
},
requests: {
send: function (msg) {
if (msg.type === 'text') {
return {
url: '//api.server.com/ask',
data: {
q: msg.content.text
}
};
}
}
}
});

bot.run();

在render表情的时候 只加载了一次

from chatui.

akai avatar akai commented on June 25, 2024

在render表情的时候 只加载了一次

能放到类似 https://codesandbox.io/ 的地方看效果吗

from chatui.

zqjimlove avatar zqjimlove commented on June 25, 2024

其实问题出在useClickOutside这个方法,当点击 Toolbar 的时候,Toolbar的click事件还在处理时(未冒泡到body)就添加了一个事件到body(调用栈在popover最开始),toolbar的click处理完后继续进行事件冒泡,冒泡到了body就触发刚才添加的click事件(即隐藏popover的处理)。

解决方案有两个,停止冒泡(但显然不合理,popover可能在别的地方也会用)。useClickOutside 添加事件时用set time out包裹,等 click 事件结束并进入下一个 eventloop 再添加事件。

from chatui.

zqjimlove avatar zqjimlove commented on June 25, 2024

至于第一次为什么可以,估计是Popover还没被初始化,也对dom进行了一次处理使浏览器进入了重排,事件冒泡也停了?具体原因需要看composer的代码。

from chatui.

akai avatar akai commented on June 25, 2024

我们的小蜜项目是没有这个问题的,我在研究一下吧有什么差异,可以临时用下面的代码解决,Pro 的话升级到 v0.2.2 :

onToolbarClick={(item, e) => {
  // handleToolbarClick(item);
  e.stopPropagation();
}}

from chatui.

akai avatar akai commented on June 25, 2024

v0.3.3 已修复

from chatui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.