Skip to content

fix(vchart): fix mark state persistence issue during updateSpec#4518

Open
xuefei1313 wants to merge 2 commits intodevelopfrom
feat/fix-issue-of-mark-state-when-updateSpec
Open

fix(vchart): fix mark state persistence issue during updateSpec#4518
xuefei1313 wants to merge 2 commits intodevelopfrom
feat/fix-issue-of-mark-state-when-updateSpec

Conversation

@xuefei1313
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

Fix an issue where mark states were not properly cleared when updateSpec was called, causing incorrect state persistence.

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.

📝 Changelog

Language Changelog
🇺🇸 English Fix mark state persistence issue during updateSpec
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

this.state.clearAllStateInfo();
this.uncommit();
this.stateStyle = {};
this.getGraphics().forEach(g => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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();
  });
}

return;
}
this._product = mark.getProduct();
this._product.clearStates();
Copy link
Contributor Author

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 相关路径。

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