Skip to content

fix: skip default select when interactions already registers element-select - #4696

Open
dyk1454683243-sudo wants to merge 2 commits into
VisActor:developfrom
dyk1454683243-sudo:cursor/fix-interactions-ismultiple-default-select-4563-e3ac
Open

dyk1454683243-sudo wants to merge 2 commits into
VisActor:developfrom
dyk1454683243-sudo:cursor/fix-interactions-ismultiple-default-select-4563-e3ac

Conversation

@dyk1454683243-sudo

@dyk1454683243-sudo dyk1454683243-sudo commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #4563

🤔 This is a ...

  • Bug fix
  • Test Case

🔗 Related issue link

Fixes #4563

💡 Background and solution

Specs that follow the official pie multi-select example:

interactions: [{ type: 'element-select', isMultiple: true }]

could not keep more than one sector selected.

Default select.enable: true still registered a single-select element-select trigger (pointertap, replace). The spec interactions entry registered a second one (click, accumulate). Those configs are not isEqual, so BaseChart._initInteractions kept both live. On click, default select applied selected first; the multi-select trigger then saw hasState and did nothing.

This change skips the default select trigger when spec.interactions already contains an element-select entry. Hover / dimension-hover defaults are unchanged.

  • Docs-shaped interactions multi-select works without select: false
  • Plain default select (no interactions) stays single-select
  • select: { mode: 'multiple' } without interactions still accumulates

📝 Changelog

Language Changelog
🇺🇸 English fix: skip default single-select when interactions already registers element-select, so isMultiple multi-select works
🇨🇳 Chinese 修复:当 interactions 已配置 element-select 时不再注册默认单选,使 isMultiple 多选生效

☑️ Self-Check before Merge

  • 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

Verification

  • eslint --quiet on packages/vchart/src/series/base/base-series.ts and the new test: clean
  • prettier --check on the same files: clean
  • jest __tests__/unit/interaction/element-select.test.ts --runner=jest-runner --testEnvironment=node: 3 passed
  • Package jest-electron runner is the default; the node runner is enough for this non-render wiring/state regression.

…select

When spec.interactions includes element-select (including isMultiple: true),
do not also register the default single-select trigger so the two do not fight.

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
@dyk1454683243-sudo
dyk1454683243-sudo marked this pull request as ready for review September 20, 2026 02:33

@xile611 xile611 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dyk1454683243-sudo 已完成 review。这个改动确实修复了饼图 interactions: [{ type: 'element-select', isMultiple: true }] 与默认单选冲突的问题,但目前会关闭自定义交互作用范围以外的默认选中,建议修复这一回归后再合并。

验证基线 c4191139a340f18f0e32dcb353c51009d88a6205 与 PR 312350584a389c56dbfc6010f6cdceb8591509b0

场景 基线 PR
饼图连续点击两个扇区(配置 selected 样式) 仅保留一个选中 正确多选
柱线组合图仅对 bar 配置 element-select,点击折线 point 正常选中 无法选中
折线图仅对 line 配置 element-select,点击 point 正常选中 无法选中

本地补充用例通过真实 VChart 创建图元,在 Node + canvas 环境显式配置 select: { trigger: 'pointertap' },通过已注册的事件处理器依次发送 pointertap / click;没有手动修改系列字段或替换图元。未做浏览器鼠标实测。PR 自带 3 个测试及修改文件的 ESLint、Prettier 均通过,但未覆盖限定 markNames 的场景。

请在解析实际匹配的图元后处理冲突,保留未被自定义交互覆盖的图元的默认选中;同时补充上述局部图元、跨系列场景的回归测试。具体位置见行内意见。

Comment on lines +960 to +963
if (interactions?.some(interaction => interaction.type === TRIGGER_TYPE_ENUM.ELEMENT_SELECT)) {
const defaultSelectIndex = res.findIndex(item => item.trigger.type === TRIGGER_TYPE_ENUM.ELEMENT_SELECT);
if (defaultSelectIndex >= 0) {
res.splice(defaultSelectIndex, 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 保留自定义交互作用范围外的默认选中

这里只要存在 element-select 就删除整个默认 select,忽略了 markNames / markIds 的作用范围。例如柱线组合图在图表级配置 interactions: [{ type: 'element-select', markNames: ['bar'], isMultiple: true }]:该配置会传给两个系列,折线系列虽然没有匹配的 bar 图元,也会先删除默认 select,随后又因匹配结果为空而不注册自定义交互,最终折线点完全无法选中。单个折线图配置 markNames: ['line'] 时,未被覆盖的 point 同样失去选中能力。上述两个场景均已验证基线通过、PR 失败。请先解析实际匹配的图元,仅处理重叠范围内的冲突,保留其他图元的默认选中,并补充回归测试。

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.

[Bug] isMultiple is not working in the interactions configuration.

3 participants