Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

💡 需求背景和解决方案

问题: 快速频繁点击 Dropdown 时,组件崩溃并报错 Cannot read properties of null (reading 'scrollHeight')

原因: dropdown-menu.tsxonMounted 中直接访问 document.querySelector().scrollHeight,但由于 Popup 设置了 destroyOnClose={true},快速开关时 DOM 元素可能尚未渲染,导致 querySelector 返回 null

修复方案: 添加 null 检查:

// Before
itemHeight.value = document.querySelector(`.${dropdownClass.value}__item`).scrollHeight + 2;

// After
const dropdownItem = document.querySelector(`.${dropdownClass.value}__item`);
if (dropdownItem) {
  itemHeight.value = dropdownItem.scrollHeight + 2;
}

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-vue-next

  • fix(dropdown): 修复快速点击时组件崩溃的问题

@tdesign-vue-next/chat

@tdesign-vue-next/auto-import-resolver

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供
Original prompt

This section details on the original issue you should resolve

<issue_title>[Dropdown] Dropdown多次点击后报错随后组件崩溃</issue_title>
<issue_description>### tdesign-vue-next 版本

1.9.9

重现链接

No response

重现步骤

image 多次点击后会直接报undefined随后组件不可用

期望结果

不影响正常功能使用

实际结果

No response

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@uyarn 准确来说应该是非常快速频繁点击的时候?组件本身有个250ms的delay效果

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…clicks

Co-authored-by: liweijie0812 <10710889+liweijie0812@users.noreply.github.com>
@liweijie0812
Copy link
Collaborator

@copilot 测试案例格式根据仓库规范来,可以参考form的

Copilot AI changed the title [WIP] Fix dropdown component crash after multiple clicks fix(dropdown): prevent crash when rapidly clicking dropdown menu Nov 28, 2025
Copilot AI requested a review from liweijie0812 November 28, 2025 13:04
Copilot finished work on behalf of liweijie0812 November 28, 2025 13:04
@liweijie0812 liweijie0812 marked this pull request as ready for review November 28, 2025 13:16
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 28, 2025

tdesign-vue-next-demo

npm i https://pkg.pr.new/Tencent/tdesign-vue-next/@tdesign-vue-next/auto-import-resolver@6201
npm i https://pkg.pr.new/Tencent/tdesign-vue-next@6201
npm i https://pkg.pr.new/Tencent/tdesign-vue-next/@tdesign-vue-next/chat@6201

commit: d03d8be

…nese)

Co-authored-by: liweijie0812 <10710889+liweijie0812@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot 测试案例格式根据仓库规范来,可以参考form的

Updated the test case comment to use Chinese, following the repository conventions. See commit d03d8be.

Copilot finished work on behalf of liweijie0812 November 28, 2025 13:25
@tdesign-bot
Copy link
Collaborator

tdesign-bot commented Nov 29, 2025

TDesign Component Site Preview Open

Component Preview
tdesign-vue-next 完成
@tdesign-vue-next/chat 完成

@liweijie0812
Copy link
Collaborator

@copilot pr模板没修改

Copy link
Contributor Author

Copilot AI commented Nov 29, 2025

@copilot pr模板没修改

已按照仓库 PR 模板格式更新 PR 描述。

Copilot finished work on behalf of liweijie0812 November 29, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dropdown] Dropdown多次点击后报错随后组件崩溃

3 participants