ChimdumebiNebolisa commented on issue #21480:
URL: https://github.com/apache/echarts/issues/21480#issuecomment-3759083824

   I’ve identified the root cause of this issue and opened a PR to fix it.
   
   ## Summary of the Issue
   When using `dispatchAction({ type: 'select', dataIndex })` on a treemap that 
contains multiple nodes with the same `name` and no explicit `id`, the 
selection logic behaves incorrectly and can select multiple nodes or fail to 
target the intended one.
   
   ## Root Cause
   Treemap selection state is stored in `selectedMap`, which is keyed using a 
“selection key”.
   
   Previously, this key was derived by **preferring `data.getName(dataIndex)` 
over `data.getId(dataIndex)`**.
   
   In treemaps, it is valid for multiple nodes to share the same `name`. When 
this happens:
   - Multiple nodes generate the same selection key
   - Entries collide in `selectedMap`
   - `dispatchAction({ type: 'select', dataIndex })` becomes non-deterministic
   
   ## Fix
   The fix updates the selection key to **always use `data.getId(dataIndex)`**, 
which is guaranteed to be unique:
   - Explicit `id` values are respected
   - When `id` is not provided, ECharts auto-generates stable unique IDs 
(`name__ec__N`)
   - Selection collisions are eliminated for duplicate names
   
   This aligns treemap selection behavior with other series types and ensures 
`dispatchAction` works reliably.
   
   ## Verification
   A minimal reproduction case was added:
   - `test/treemap-select-21480.html`
   - Uses duplicate node names (`"same"`)
   - Dispatches a `select` action for a specific `dataIndex`
   - Confirms only the intended node is selected (`selectedIndices === [3]`)
   
   ## PR
   A PR has been opened containing:
   - The core fix in `src/model/Series.ts`
   - Updated dist artifacts
   - A reproducible test case for validation
   
   This resolves the issue without affecting existing behavior for series that 
already rely on IDs.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to