Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

🤔 这个 PR 的性质是?

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

🔗 相关 Issue

closes #3413

💡 需求背景和解决方案

当 Popconfirm 弹出层显示后快速连点取消/确定按钮时,控制台报错:

Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

根因useRipple hook 在调用 getComputedStyle() 前未校验元素有效性。当 popup 快速关闭时,按钮元素已从 DOM 移除,但 ripple 动画代码仍在尝试获取其计算样式。

修复:在 packages/shared/hooks/useRipple/index.ts 中添加 instanceof Element 校验:

  • getRippleColor 函数中获取 CSS 变量前
  • handleAddRipple 函数入口处
  • 后续 getComputedStyle 调用前(防御性检查)

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-vue-next

  • fix(popconfirm): 修复快速点击取消/确定按钮时 getComputedStyle 报错的问题

@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>[Popconfirm] 当显示弹出层后,快速连点按钮时报错</issue_title>
<issue_description>### tdesign-vue-next 版本

1.5.6

重现链接

https://tdesign.tencent.com/vue-next/components/popconfirm?tab=demo

重现步骤

  1. 点击示例中的删除按钮
  2. 显示弹出层后,快速点击[取消]或[确定]按钮
  3. 控制台报错 Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

期望结果

无报错

实际结果

Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

框架版本

Vue 3.3.4

浏览器版本

116.0.5845.187

系统版本

MacOS 11.5.2

Node版本

16.17.0

补充说明

No response</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 30, 2025 08:20
Co-authored-by: liweijie0812 <10710889+liweijie0812@users.noreply.github.com>
Co-authored-by: liweijie0812 <10710889+liweijie0812@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error when quickly clicking buttons in Popconfirm fix(popconfirm): 修复快速点击按钮时报错 getComputedStyle Nov 30, 2025
Copilot AI requested a review from liweijie0812 November 30, 2025 08:31
Copilot finished work on behalf of liweijie0812 November 30, 2025 08:31
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 30, 2025

  • tdesign-vue-next-demo

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

commit: e78a212

@tdesign-bot
Copy link
Collaborator

tdesign-bot commented Nov 30, 2025

TDesign Component Site Preview Open

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

@liweijie0812 liweijie0812 marked this pull request as ready for review November 30, 2025 09:22
@liweijie0812 liweijie0812 changed the title fix(popconfirm): 修复快速点击按钮时报错 getComputedStyle fix(popconfirm): 修复快速点击按钮时 getComputedStyle 报错 Nov 30, 2025
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.

[Popconfirm] 当显示弹出层后,快速连点按钮时报错

3 participants