Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛[BUG] 调整页面比例后聊天框一直逐渐变小 #251

Closed
sinianluoye opened this issue Jun 15, 2024 · 2 comments · Fixed by #252
Closed

🐛[BUG] 调整页面比例后聊天框一直逐渐变小 #251

sinianluoye opened this issue Jun 15, 2024 · 2 comments · Fixed by #252
Labels
bug Something isn't working

Comments

@sinianluoye
Copy link

🐛 bug 描述

调整页面比例后聊天框会逐渐变小,官网组件页即可复现

📷 复现步骤

调整页面比例后聊天框会逐渐变小,官网组件页即可复现

1.mp4

🏞 期望结果

不触发此类效果

💻 复现代码

官网组件页即可复现

© 版本信息

  • @ant-design/pro-chat 版本: [e.g. 1.0.0]
  • edge

🚑 其他信息

已经在个人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);
          }
        }}
@sinianluoye sinianluoye changed the title 🐛[BUG] 聊天框一直逐渐变小 🐛[BUG] 调整页面比例后聊天框一直逐渐变小 Jun 15, 2024
@ONLY-yours ONLY-yours added the bug Something isn't working label Jun 18, 2024
@ONLY-yours
Copy link
Collaborator

神奇的 bug 哈哈哈

@ONLY-yours
Copy link
Collaborator

@sinianluoye 直接给我们提一个 pr 合并进来呢 哈哈哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants