You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "aloktomarr (via GitHub)" <gi...@apache.org> on 2026/07/17 12:07:46 UTC

[PR] fix(dataZoom): skip redundant reset when only the origin snapshot rem… [echarts]

aloktomarr opened a new pull request, #21695:
URL: https://github.com/apache/echarts/pull/21695

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Stops the toolbox dataZoom "back"/zoom-reset from dispatching a redundant action once the chart is already back at its original range.
   
   ### Fixed issues
   
   - close #21660
   
   ## Details
   
   ### Before: What was the problem?
   
   The dataZoom zoom history keeps the original (un-zoomed) range as the base snapshot, then pushes one snapshot per zoom. `history.pop()` did not stop when only that base snapshot remained — it still returned the origin as a restorable snapshot. So the toolbox "back"/zoom-reset could be triggered one extra time (e.g. 3× after 2 zooms across multiple grids), dispatching a redundant `dataZoom` action that "restores" a range that is already current.
   
   Reproduction (from #21660): open the `grid-multiple` example, zoom the upper chart once and the lower chart once (2 zooms), then click Zoom Reset — it can be triggered 3 times.
   
   ### After: How does it behave after the fixing?
   
   `history.pop()` now returns an empty snapshot when only the origin remains (nothing left to undo). Its only caller — the toolbox dataZoom `back` handler — already guards on `batch.length`, so no redundant `dataZoom` action is dispatched. After 2 zooms, reset now triggers exactly 2 times.
   
   Added a unit test (`test/ut/spec/component/dataZoom/history.test.ts`) covering push/pop/count and the regression: popping when only the origin remains returns `{}`.
   
   ## Document Info
   
   - [x] This PR doesn't relate to document changes
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   Unit test: `test/ut/spec/component/dataZoom/history.test.ts`
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] fix(dataZoom): skip redundant reset when only the origin snapshot rem… [echarts]

Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #21695:
URL: https://github.com/apache/echarts/pull/21695#issuecomment-5003102676

   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
   
   Please **DO NOT** commit the files in [dist](https://github.com/apache/echarts/tree/master/dist), [i18n](https://github.com/apache/echarts/tree/master/i18n), and [ssr/client/dist](https://github.com/apache/echarts/tree/master/ssr/client/dist) folders in a non-release pull request. These folders are for release use only.


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org