Closed sinianluoye closed 3 months ago
调整页面比例后聊天框会逐渐变小,官网组件页即可复现
vedio
不触发此类效果
官网组件页即可复现
已经在个人fork的仓库中进行修复 https://github.com/sinianluoye/pro-chat/pull/2/files
bug触发的原因是src/ProChat/container/App.tsx下 RcResizeObserver组件的onResize函数调用setHeight后height和e.height始终存在一个很小的差值,导致一直触发onResize事件
onResize={(e) => { if (e.height !== height) { setHeight(e.height); } }
修改后的代码为
onResize={(e) => { if ((typeof height !== typeof e.height) || (typeof height === 'string' && typeof e.height === 'string' && e.height !== height) || (typeof height === 'number' && Math.abs(e.height - height) > 1)) { // 加一个 Math.abs(e.height - height) > 1 的判断以避免height和e.height相差过小导致的页面一直缩小 setHeight(e.height); } }}
神奇的 bug 哈哈哈
@sinianluoye 直接给我们提一个 pr 合并进来呢 哈哈哈
🐛 bug 描述
调整页面比例后聊天框会逐渐变小,官网组件页即可复现
📷 复现步骤
调整页面比例后聊天框会逐渐变小,官网组件页即可复现
vedio
🏞 期望结果
不触发此类效果
💻 复现代码
官网组件页即可复现
© 版本信息
🚑 其他信息
已经在个人fork的仓库中进行修复 https://github.com/sinianluoye/pro-chat/pull/2/files
bug触发的原因是src/ProChat/container/App.tsx下 RcResizeObserver组件的onResize函数调用setHeight后height和e.height始终存在一个很小的差值,导致一直触发onResize事件
修改后的代码为