Repository navigation
Conversation
…veTo does not crash. close apache#18402 `customInnerStore(el).option` is read when a custom series element or a group child is removed, to apply the leave transition, but it was never set. So removing an element that has `leaveTo` threw a TypeError.
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
Save the element option on custom series elements, so that removing an element that has
leaveTono longer throws.Fixed issues
Details
Before: What was the problem?
When a custom series element that has
leaveTois removed, the chart throws. This happens whensetOptionis called with fewer data items, and also when a group returned byrenderItemgets fewer children:CustomViewpassescustomInnerStore(el).optiontoapplyLeaveTransitionin three places:renderremoveChildFromGroup(it passes the option of the parent group)processRemove, when$mergeChildren: 'byName'is usedBut
customInnerStore(el).optionis never assigned, so it is alwaysundefined. Elements withoutleaveToare not affected, becauseapplyLeaveTransitiononly reads the option when there is a leave animation to play. These reads came in 5.3.0, when the transition code of the custom series moved tocustomGraphicTransition.ts. In 5.2.x the leave animation did not need the element option.After: How does it behave after the fixing?
doCreateOrUpdateElnow saves the option withcustomInnerStore(el).option = elOption;, right afterinfois saved. This line runs for every element: new or reused, at the root or inside a group. It also runs beforemergeChildren, so a group already has its option whenremoveChildFromGroupreads it. Removed elements now play theirleaveToanimation and are taken out of the group when it ends.#18075 had the same idea and set the option in
createEl. It was closed as stale, and the test case asked for in its review was never added. This PR sets the option indoCreateOrUpdateElinstead, so the saved option is also refreshed when an existing element is updated, and it adds unit tests. As explained in the review of #18075, the leave transition still uses theupdateanimation config. This PR does not change that.Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
New unit tests in
test/ut/spec/series/custom.test.ts, one for each of the three places above:leaveTo(the setup from the issue): one element is removed right after it was created, and the other is removed after it was updatedleaveTo, with children merged by indexleaveTo, with$mergeChildren: 'byName'Each test checks that
setOptiondoes not throw and that the removed elements are gone once the leave animation has ended. Without the fix, all three tests fail with theTypeErrorabove.Checks run locally:
npm run test: 33 test suites, 229 tests passednpm run lint: no errorsnpm run checktype: no errorsnpm run checkheader: passedMerging options
Other information
None.