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

Fix initialValue block setting #5978

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix initialValue block setting #5978

wants to merge 2 commits into from

Conversation

wesleybl
Copy link
Member

@wesleybl wesleybl commented Apr 23, 2024

This fixes initialValue block setting in two situations:

  • When the previous block is an empty block:

In this situation, only the onChangeBlock method was called, which does not call the applyBlockInitialValue method. Then we call the applyBlockInitialValue method before calling onChangeBlock.

  • When the previous block is not an empty block:

In this situation, the insertBlock method is called. But it passed the id of the previous block to the applyBlockInitialValue method, instead of the id of the new created block.

fixes #5971

Copy link

netlify bot commented Apr 23, 2024

Deploy Preview for volto canceled.

Name Link
🔨 Latest commit 5588d72
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/6638fafc6f7cd30008aa449d

Copy link

netlify bot commented Apr 23, 2024

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit 5588d72
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/6638fafc7ccd4c000844ab01

@wesleybl wesleybl requested a review from sneridagh April 23, 2024 20:56
@@ -39,6 +39,7 @@ export {
getLanguageIndependentFields,
} from '@plone/volto/helpers/Content/Content';
export {
_applyBlockInitialValue,
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@wesleybl Usually when you have a method that starts with _ it's implied that it is private.
I don't think it should thus be exported for helpers, if that is the case that it would be useful
for add-ons to call this helper then I would remove the _.
Ex info
https://css-tricks.com/implementing-private-variables-in-javascript/#aa-using-an-underscore
but if you google js private convention you will see that this was very popular before true private
fields

Copy link
Member Author

Choose a reason for hiding this comment

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

@ichim-david I thought about this when I was implementing it, but I thought renaming a function could be a big change. But as it was a local function of the module, I don't think it will be a big problem. I'll rename it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ichim-david done.

In this situation, only the onChangeBlock method was called, which does
not call the _applyBlockInitialValue method. Then we call the
_applyBlockInitialValue method before calling onChangeBlock.
block

In this situation, the insertBlock method is called. But it passed the
id of the previous block to the _applyBlockInitialValue method, instead
of the id of the new created block.
@wesleybl wesleybl requested a review from ichim-david May 6, 2024 15:54
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.

initialValue block setting doesn't work
2 participants