Skip to content

fix(states): guard against undefined view in blurSeries#21560

Open
davesecops wants to merge 1 commit intoapache:masterfrom
davesecops:fix-21559
Open

fix(states): guard against undefined view in blurSeries#21560
davesecops wants to merge 1 commit intoapache:masterfrom
davesecops:fix-21559

Conversation

@davesecops
Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Adds a null guard in blurSeries() to prevent a TypeError when api.getViewOfSeriesModel() returns undefined for disposed series during mouse events.

Fixed issues

Details

Before: What was the problem?

In blurSeries() (src/util/states.ts), api.getViewOfSeriesModel(seriesModel) can return undefined when a series model still exists in GlobalModel but its view has been disposed during a React/Vue re-render cycle (via setOption with notMerge, or component unmount). The code unconditionally accesses view.group:

const view = api.getViewOfSeriesModel(seriesModel);
view.group.traverse(function (child) {  // 💥 TypeError if view is undefined

This is triggered by mousemove events that fire on stale DOM elements during the window between disposal and re-creation. The call path is:

HandlerDomProxy.mousemove → Handler.mousemove → Handler.dispatchToElement →
Eventful.trigger → handleGlobalMouseOverForHighDown → blurSeries →
eachSeries callback → view.group.traverse  💥

After: How does it behave after the fixing?

const view = api.getViewOfSeriesModel(seriesModel);
if (!view || !view.group) {
    return;
}
view.group.traverse(function (child) {

The blur effect is simply skipped for disposed series — consistent with the existing pattern in toggleSeriesBlurState and allLeaveBlur which already handle undefined views gracefully.

Related test cases or examples to use the new APIs

This is a race condition triggered by real user mouse interaction during framework re-renders. The fix is defensive — it prevents a crash on a code path that can legitimately receive undefined, matching patterns already used elsewhere in the same file.

Document Info

  • This PR doesn't relate to document changes

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes.

Merging options

  • Please squash the commits into a single one when merging.

Other information

This is a 3-line addition (null guard + return + closing brace). It is the same class of bug addressed in #21537 (getDataParams null guard) — both stem from stale series references during mouse events on disposed charts. This PR specifically guards the blurSeriesview.group access path which is not covered by the getDataParams fix.

Author: David Langlands david@grantllama.com
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

When a chart series is disposed during a React/Vue re-render cycle
(via setOption with notMerge, or component unmount), the series model
may still exist in GlobalModel but its view has been disposed.

blurSeries() iterates all series via eachSeries() and calls
api.getViewOfSeriesModel(seriesModel), which returns undefined for
disposed series. The subsequent view.group.traverse() then crashes
with "Cannot read properties of undefined (reading 'group')".

This is triggered by mousemove events that fire on stale DOM elements
during the window between disposal and re-creation.

Add a null guard after the view lookup, consistent with the pattern
used elsewhere in the codebase (e.g., toggleSeriesBlurState).

Fixes apache#21559

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@echarts-bot
Copy link
Copy Markdown

echarts-bot bot commented Mar 30, 2026

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant