Skip to content

fix(tooltip): 修复页面滚动时tooltip不自动隐藏的问题#3310

Merged
Alexzjt merged 4 commits intonextfrom
copilot/fix-issue-3307-bug
Feb 4, 2026
Merged

fix(tooltip): 修复页面滚动时tooltip不自动隐藏的问题#3310
Alexzjt merged 4 commits intonextfrom
copilot/fix-issue-3307-bug

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 30, 2026

当页面可滚动时,点击单元格弹出tooltip后,在表格区域外滚动页面,tooltip不会自动消失,与单元格产生错位。

修改内容

  • 事件类型: OriginEventType 新增 SCROLL 类型
  • 滚动监听: EventController.bindEvents() 添加 window scroll 事件监听,滚动时调用 hideTooltip()
  • 性能优化: 使用 throttle(16ms) 节流,存储为类属性 onScroll 确保事件清理正确
  • 测试: 新增 scroll 事件隐藏 tooltip 的测试用例
// event-controller.ts
private onScroll = throttle(() => {
  this.spreadsheet.hideTooltip();
}, 16);

// bindEvents()
this.addDomEventListener(window, OriginEventType.SCROLL, this.onScroll);

Solve the issue and close #3307

Original prompt

分析issue #3307 是否是本仓库的代码bug,如果是,请进行修复,并解释修复思路。最终提交的PullRequest的标题和描述都应该是中文的。Pull Request的描述中需要Solve the issue and close #3307


💡 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 changed the title [WIP] 修复代码中的bug并解决#3307 fix(tooltip): 修复页面滚动时tooltip不自动隐藏的问题 Jan 30, 2026
Copilot AI requested a review from Alexzjt January 30, 2026 09:28
@Alexzjt Alexzjt marked this pull request as ready for review January 31, 2026 13:55
@github-actions github-actions bot added next 2.0-next 版本的问题 pr(fix) bug fix labels Jan 31, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 31, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.82%. Comparing base (ecdc9c8) to head (8bc7e90).
⚠️ Report is 776 commits behind head on next.

Files with missing lines Patch % Lines
...ckages/s2-core/src/interaction/event-controller.ts 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3310      +/-   ##
==========================================
+ Coverage   75.77%   78.82%   +3.05%     
==========================================
  Files         257      224      -33     
  Lines       11994    12425     +431     
  Branches     2464     2802     +338     
==========================================
+ Hits         9088     9794     +706     
+ Misses       1398      946     -452     
- Partials     1508     1685     +177     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

Size Change: -143 B (-0.02%)

Total Size: 739 kB

Filename Size Change
./packages/s2-core/dist/s2-extends.min.js 207 kB -66 B (-0.03%)
./packages/s2-core/dist/s2.min.css 581 B -2 B (-0.34%)
./packages/s2-core/dist/s2.min.js 308 kB -75 B (-0.02%)
ℹ️ View Unchanged
Filename Size
./packages/s2-react-components/dist/s2-react-components.min.css 2.55 kB
./packages/s2-react-components/dist/s2-react-components.min.js 123 kB
./packages/s2-react/dist/s2-react.min.css 1.3 kB
./packages/s2-react/dist/s2-react.min.js 38.5 kB
./packages/s2-vue/dist/s2-vue.min.css 3.8 kB
./packages/s2-vue/dist/s2-vue.min.js 54.2 kB

compressed-size-action

@Alexzjt
Copy link
Copy Markdown
Contributor

Alexzjt commented Feb 4, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 旨在修复页面滚动时 tooltip 不会自动隐藏的问题。通过在 window 对象上添加一个节流的 scroll 事件监听器,在页面滚动时调用 hideTooltip 方法,有效地解决了 tooltip 与单元格错位的问题。代码实现简洁明了,通过 throttle 进行了性能优化,并且添加了对应的单元测试,覆盖了核心逻辑。整体修改质量很高,我只有一个关于代码可读性的建议。

@Alexzjt Alexzjt merged commit e7a02bb into next Feb 4, 2026
15 checks passed
@Alexzjt Alexzjt deleted the copilot/fix-issue-3307-bug branch February 4, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next 2.0-next 版本的问题 pr(fix) bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛tooltip不能随页面滚动调整位置

3 participants