fix: consider default style when computing effective style properties - #152
Merged
tbouffard merged 6 commits intoDec 17, 2022
Merged
Conversation
The StyleSheet.getCellStyle didn't keep the properties of the default style when `baseStyleNames` was set in the `cellStyle` parameter. The JSDoc was incorrect (it came from mxGraph) about how the style is computed, in particular about the default style. It probably leads to the erroneous implementation during migration. It is now fixed and clearly describe the rules followed to merge style properties. The 'Stylesheet' has been updated to correctly use the maxGraph API. It also includes more examples involving `baseStyleNames` to show the 'properties merge' in action. Introduce `jest` to test the fix and the whole implementation of the changed method. Types check support is provided by `ts-jest`. As maxGraph uses a lot of browser objects, also setup `jest-jsdom-environment`.
tbouffard
marked this pull request as ready for review
December 13, 2022 15:19
This was referenced Dec 14, 2022
junsikshim
approved these changes
Dec 17, 2022
junsikshim
left a comment
Collaborator
There was a problem hiding this comment.
I think this is a great step forward.
Testing a few examples from the storybook was definitely not enough to ensure the robustness of the change.
tbouffard
deleted the
fix/use_default_style_when_accumulate_all_styles
branch
December 17, 2022 08:16
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.
Summary
StyleSheet.getCellStyledidn't keep the properties of the default style whenbaseStyleNameswas set in thecellStyleparameter.The JSDoc was incorrect (it came from mxGraph) about how the style is computed, in particular about the default style. It probably leads to the erroneous implementation during migration. It is now fixed and clearly describe the rules followed to merge style properties.
The 'Stylesheet' story has been updated to correctly use the maxGraph API (with the help of #88). It also includes more examples involving
baseStyleNamesto show the 'properties merge' in action.The following screenshots of the story show what happened prior the fix
As a reminder, here is how the example looks with
mxGraph:Description for the changelog
StyleSheet.getCellStylemerges all the properties of the default style whenbaseStyleNamesis set in thecellStyleparameter.Possible root cause of the issue
The API documentation of mxGraph and typed-mxgraph used during the maxGraph migration was wrong and didn't reflect what the code does.
The change of the style from a string representation (#82) to an object probably introduced the regression, especially because the API doc was incomplete and wrong.
I reviewed the PR myself and didn't notice the problem. There were no example to demonstrate the feature and to test it.
We now have automatic unit tests and examples, so this situation shouldn't appear again.
Other info
Introduce
jestto test the fix and the whole implementation of the changed method. Types check support is provided byts-jest. As maxGraph uses a lot of browser objects, also setupjest-jsdom-environment.This is a starting point. I created a discussion about a test strategy and choosing the test framework: #153.
In the short term, I would like to see this PR merged as is to move forward (see discussion for details).