-
Notifications
You must be signed in to change notification settings - Fork 209
fix(vchart): fix mark state persistence issue during updateSpec #4518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xuefei1313
wants to merge
2
commits into
develop
Choose a base branch
from
feat/fix-issue-of-mark-state-when-updateSpec
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...anges/@visactor/vchart/feat-fix-issue-of-mark-state-when-updateSpec_2026-03-17-06-14.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "comment": "update changes for 009-fix-issue-of-mark-state-when-updateSpec: Fix an issue where mark states were not properly cleared when updateSpec was called, causing incorrect state persistence.", | ||
| "type": "none", | ||
| "packageName": "@visactor/vchart" | ||
| } | ||
| ], | ||
| "packageName": "@visactor/vchart", | ||
| "email": "lixuef1313@163.com" | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1087,7 +1087,11 @@ export class BaseMark<T extends ICommonSpec> extends GrammarItem implements IMar | |
| return; | ||
| } | ||
| this._product = mark.getProduct(); | ||
| this._product.clearStates(); | ||
| this._graphics = mark.getGraphics(); | ||
| this._graphics.forEach(g => { | ||
| g.clearStates(); | ||
| }); | ||
| this._graphicMap = (mark as any)._graphicMap; | ||
|
|
||
| this._graphicMap.forEach(g => { | ||
|
|
@@ -2056,4 +2060,13 @@ export class BaseMark<T extends ICommonSpec> extends GrammarItem implements IMar | |
| runAnimation() { | ||
| this._runStateAnimation(this.getGraphics()); | ||
| } | ||
|
|
||
| clearBeforeReInit() { | ||
| this.state.clearAllStateInfo(); | ||
| this.uncommit(); | ||
| this.stateStyle = {}; | ||
| this.getGraphics().forEach(g => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clearBeforeReInit 目前只对 getGraphics() 返回的图元调用了 clearStates(),但不会清理 mark 的 _product(group)与 _graphicMap 上已有的 states。建议在重载前同时清理这些对象的 states,避免 state 写入时产生残留。 参考建议: clearBeforeReInit() {
this.state.clearAllStateInfo();
this.uncommit();
this.stateStyle = {};
this._product?.clearStates();
this._graphics.forEach(g => {
g.clearStates();
});
this._graphicMap.forEach(g => {
g.clearStates();
});
} |
||
| g.clearStates(); | ||
| }); | ||
| } | ||
| } | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Implementation Plan: Fix mark state issue during updateSpec | ||
|
|
||
| ## Summary | ||
| Fix an issue where mark states were not properly cleared when `updateSpec` was called, causing incorrect state persistence. | ||
|
|
||
| ## Technical Context | ||
| The `updateSpec` process re-initializes marks but previous state information was lingering. | ||
| Changes include: | ||
| - Added `clearAllStateInfo` method to `IMarkStateManager` interface and implementation. | ||
| - Added `clearBeforeReInit` method to `IMarkRaw` interface and implementation. | ||
| - Invoked `clearBeforeReInit` in `BaseMark` during re-initialization. | ||
| - Updated `BaseSeries` to handle state cleanup during spec updates. | ||
|
|
||
| ### Source Code (repository root) | ||
| ``` | ||
| packages/vchart/src/compile/mark/interface.ts | ||
| packages/vchart/src/compile/mark/mark-state-manager.ts | ||
| packages/vchart/src/mark/base/base-mark.ts | ||
| packages/vchart/src/mark/interface/common.ts | ||
| packages/vchart/src/series/base/base-series.ts | ||
| ``` | ||
|
|
||
| ## Verification Plan | ||
| - Verify that mark states (e.g., hover, select) are reset correctly after `updateSpec`. | ||
| - Ensure no regression in normal state interactions. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseMark.reuse 中无条件清理 states 会导致交互态(hover/select 等)在非 updateSpec 路径(如常规 compile)中被重置。建议确认是否应将清理逻辑更精准地收敛在 reInit/updateSpec 相关路径。