fix(states): guard against undefined view in blurSeries#21560
Open
davesecops wants to merge 1 commit intoapache:masterfrom
Open
fix(states): guard against undefined view in blurSeries#21560davesecops wants to merge 1 commit intoapache:masterfrom
davesecops wants to merge 1 commit intoapache:masterfrom
Conversation
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>
|
Thanks for your contribution! 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. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Brief Information
This pull request is in the type of:
What does this PR do?
Adds a null guard in
blurSeries()to prevent a TypeError whenapi.getViewOfSeriesModel()returnsundefinedfor disposed series during mouse events.Fixed issues
Details
Before: What was the problem?
In
blurSeries()(src/util/states.ts),api.getViewOfSeriesModel(seriesModel)can returnundefinedwhen a series model still exists inGlobalModelbut its view has been disposed during a React/Vue re-render cycle (viasetOptionwithnotMerge, or component unmount). The code unconditionally accessesview.group:This is triggered by
mousemoveevents that fire on stale DOM elements during the window between disposal and re-creation. The call path is:After: How does it behave after the fixing?
The blur effect is simply skipped for disposed series — consistent with the existing pattern in
toggleSeriesBlurStateandallLeaveBlurwhich 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
Misc
Security Checking
ZRender Changes
Merging options
Other information
This is a 3-line addition (null guard + return + closing brace). It is the same class of bug addressed in #21537 (
getDataParamsnull guard) — both stem from stale series references during mouse events on disposed charts. This PR specifically guards theblurSeries→view.groupaccess path which is not covered by thegetDataParamsfix.Author: David Langlands david@grantllama.com
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com