Skip to content
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

Initialize data in form before the checks for the blocks and blocks_layout are done #5445

Merged
merged 6 commits into from
Nov 30, 2023

Conversation

sneridagh
Copy link
Member

This fix an edge case when the data from the server content is empty, then the fields are populated, but the initialized data is snapshot after the check (and amendments) are done.

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for volto canceled.

Name Link
🔨 Latest commit ca8e36f
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/65686c4f7f5c560007f501c4

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea how to reproduce the bug for testing, but it looks reasonable.

Copy link
Contributor

@tiberiuichim tiberiuichim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it, as we're baking in default empty form in that initial data, so it's no longer the same as the data that comes from the server. But this has me thinking: it's a smell of something rotten somewhere else. How about we don't initialize an empty form if the server is still pending data?

@sneridagh
Copy link
Member Author

The edge case: A content type created programatically, having blocks and blocks_layout empty. Then, this code was in place to catch it, but if the snapshot happens after the init, then the comparison that rips out all non-changed data using the snapshot is wrong, then it does not includes the blocks_layout, so it keeps being empty. This was not happening, if you add further blocks than the default in the first edit.

Agreed that this should happen in the server probably if the data exists and it's wrong.

* main:
  Move dangling news item to the right place
  Better start script in root package.json, enable and better config for husky/lint-staged
  All in with monorepo (#5409)
  changed toNumber to parseFloat   #5447 (#5448)
  Release 18.0.0-alpha.3
  Changelog
  Revert "Improvements and completeness of the ContentMetadataTags component (#5433)" (#5449)
@sneridagh sneridagh merged commit 49f8d45 into main Nov 30, 2023
46 checks passed
@sneridagh sneridagh deleted the edgecaseblocksdefaultsincasetheyareempty branch November 30, 2023 11:23
sneridagh added a commit that referenced this pull request Dec 13, 2023
pranayjoshi pushed a commit to pranayjoshi/volto that referenced this pull request Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants