fix: contextmenu cant be scrolled#7638
Conversation
There was a problem hiding this comment.
Code Review
This pull request moves the registration of the wheel event listener for the context menu from the initialization phase to the bindEvents method, which prevents wheel events from bubbling up and triggering canvas zoom logic. A review comment identifies a potential issue where the context menu might close unexpectedly when users interact with internal elements like scrollbars, suggesting an improvement to the click handling logic to ensure better usability.
|
|
||
| document.addEventListener('click', this.onMenuItemClick); | ||
| // 阻止滚轮事件冒泡,防止触发画布的 zoom-canvas 拦截逻辑 | ||
| this.$element.addEventListener('wheel', this.wheelHandler); |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v5 #7638 +/- ##
=======================================
Coverage 94.95% 94.95%
=======================================
Files 188 188
Lines 10031 10031
Branches 2171 2171
=======================================
Hits 9525 9525
Misses 468 468
Partials 38 38
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
修复Contextmenu无法滚动的问题
Graph 初始化时,Contextmenu 的这三个函数触发顺序是这样的
initElement()->unbindEvents()->bindEvents(),导致wheelHandler添加后接着被移除将
addEventListener从initElement中移动到bindEvents即可解决