fix echarts this.mouse - #8041
Merged
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8041 +/- ##
==========================================
- Coverage 87.08% 86.11% -0.97%
==========================================
Files 346 346
Lines 53717 53717
==========================================
- Hits 46780 46259 -521
- Misses 6937 7458 +521 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
philippjfr
approved these changes
Jul 11, 2025
philippjfr
left a comment
Member
There was a problem hiding this comment.
Not sure why this is needed tbh but if it works, it works.
philippjfr
enabled auto-merge (squash)
July 11, 2025 07:26
philippjfr
disabled auto-merge
July 11, 2025 08:26
philippjfr
pushed a commit
that referenced
this pull request
Jul 11, 2025
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing #7889
I don't fully understand the fix from GPT 4.1. But its simple and the Echarts events works for me in both edge and firefox after the change.
echarts-this.mouse-firefox.mp4
GPT 4.1 explanation
The error described in #fetch (TypeError: this.mouse is not a function at Object.pointer) occurs when handling mouse events like mouseover in ECharts, specifically in Edge (but not Firefox).
Looking at echarts.ts, mouse events are handled by the EChartsView._subscribe() method. For each event in event_config, it attaches a callback that serializes the event using serializeEvent:
The error trace points to a problem inside serializeEvent, specifically when it tries to call this.mouse. In event-to-object.ts, there is a class EventTransformCategories with a mouse method, but the context (this) may be lost if the method is called incorrectly (e.g., as a plain function instead of a method).
Root cause:
If EventTransformCategories.mouse is called without binding to an instance, this is undefined, so this.mouse fails. This can happen if the code does something like elementTransformCategoriescategorycategory instead of elementTransformCategories.mouse.call(instance, event).
Why Edge but not Firefox?
Edge may be stricter about this binding in certain contexts, or the event object structure may differ, triggering the bug only in Edge.
How to fix:
Ensure that all methods in EventTransformCategories are called with the correct this context, e.g., by using .call(instance, event) or converting them to static methods if they don't rely on instance state.
Summary:
The bug is caused by incorrect method binding in the event serialization logic, leading to this.mouse is not a function when handling mouse events in Edge. Fix the binding in serializeEvent to resolve the issue.
EChartsView
serializeEvent
EventTransformCategories
Similar code found with 1 license type - V