-
Notifications
You must be signed in to change notification settings - Fork 0
Custom serializer + list bug #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 1.16%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
e6949b0
to
69fa475
Compare
…list This commit fixes a bug where the rendering of a node can fail if it has fields not supported by Block and follows directly after a list item. The list item logic would pass in the first node after the list as context and cast it to a Block. This fails if the node has fields not supported by Block. Which is the case for custom serializer blocks. The context is actually not used, and removing it solves the bug.
I made the tests fail first so you can confirm the fix fixes the bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look at this, but it's a bit hard for me to understand what the original problem was and how it behaves after the fix. Could you update the description and provide some examples on before/after? 😇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to admit my portable-text knowledge is getting a little rusty, so I'm not easily able to judge whether the JSON added is valid or not - but I trust you 🙂 The code change looks harmless as well, and seeing that all tests are green, I'm fairly sure this is fine to merge 👍
Thanks for adding the failing test first. Definitely makes it much easier to review.
Good point, it is quite hard to understand. Took me hours just to find what caused the bug 😅 I added some screenshots to at least explain the situation from a user perspective. Merging ang releasing the change. |
Codecov Report
@@ Coverage Diff @@
## main #44 +/- ##
=====================================
Coverage 92.1% 92.1%
=====================================
Files 7 7
Lines 307 307
Branches 57 57
=====================================
Hits 283 283
Misses 13 13
Partials 11 11
|
What
This PR fixes a bug where the rendering of a node can fail if it has fields not supported by Block and follows directly after a list item.
The list item logic would pass in the first node after the list as context and cast it to a Block. This fails if the node has fields not supported by Block. Which is the case for custom serializer blocks.
The context is actually not used, and removing it solves the bug.
What used to not work?
A custom element right after a list of some kind.
signatures
is what makes the code fail