Raman-Katiyar opened a new pull request, #21818:
URL: https://github.com/apache/echarts/pull/21818

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Fixes the graphic component losing previously set element properties (e.g. 
`style`) when an element is added with `lazyUpdate: true` and then updated by a 
following `setOption`.
   
   ### Fixed issues
   
   - #20924: [Bug] graphic component abnormal in `lazyUpdate: true`
   
   ## Details
   
   ### Before: What was the problem?
   
   Following the reproduction in #20924: a graphic `rect` is added with
   `setOption(option, {notMerge: true, lazyUpdate: true})` with
   `style: {fill: 'rgba(0,150,0,0.5)'}`, and a second `setOption` with
   `lazyUpdate: true` then updates only the element's `shape`. The rect is
   rendered **black** instead of green — the `style` from the first call is 
lost.
   With `lazyUpdate: false` the same sequence behaves correctly.
   
   Root cause: with `lazyUpdate: true` the first `setOption` is not rendered
   before the second one arrives, so the second `setOption` works on a model
   whose graphic option is restored from the option backup. The element options
   in that backup are the raw user input and were never merged with each other,
   and the pending element updates of the first call are discarded during the
   restore — so the view only ever receives the second call's delta. On top of
   that, `copyTransitionInfo` creates an empty `style: {}` placeholder on the
   delta option, which resets the element's style when it is applied.
   
   ### After: How does it behave after the fixing?
   
   The behaviour is now identical regardless of `lazyUpdate`: properties set by
   an earlier `setOption` are kept when a later update only specifies some of
   them (the rect stays green and takes the new shape).
   
   In `GraphicModel`, when an element option is merged into the existing one,
   the properties of `shape`, `style` and `extra` that the new option does not
   specify are now also copied from the existing element option into the option
   handed to the view (new helper `copyUnspecifiedNestedProps`), so the view
   always renders the fully merged result. The model option itself
   (`getOption()`) was already merged correctly and is unchanged.
   
   Validation performed locally:
   
   - New regression test `lazyUpdateKeepsElementStyle` in
     `test/ut/spec/component/graphic/setOption.test.ts`, following the exact
     steps of #20924: it **fails without this fix** (the rendered element's
     `style` is empty) and **passes with it**.
   - Graphic, model and api unit suites: 9 suites, 78 tests — all pass.
   - Full unit test suite: 26 suites, 195 tests — all pass.
   - `npm run checktype` — pass.
   - ESLint on the changed files — pass.
   - `npm run build` — pass.
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   ## 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
   
   `test/ut/spec/component/graphic/setOption.test.ts` — new case
   `lazyUpdateKeepsElementStyle`; the demo linked in #20924 can also be used
   to verify manually (green rect before and after the fix scenario).
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   
   This is a single commit on a fresh branch from `master`, touching only
   `src/component/graphic/GraphicModel.ts` and its unit test.
   
   Could a maintainer please approve the CI workflow run for this PR? Thank you!


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