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: [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