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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for volto canceled.
|
✅ Deploy Preview for plone-components canceled.
|
packages/volto/src/helpers/index.js
Outdated
@@ -39,6 +39,7 @@ export { | |||
getLanguageIndependentFields, | |||
} from '@plone/volto/helpers/Content/Content'; | |||
export { | |||
_applyBlockInitialValue, |
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.
@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
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.
@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.
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.
@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.
This fixes
initialValue
block setting in two situations:In this situation, only the
onChangeBlock
method was called, which does not call theapplyBlockInitialValue
method. Then we call theapplyBlockInitialValue
method before callingonChangeBlock
.In this situation, the
insertBlock
method is called. But it passed the id of the previous block to theapplyBlockInitialValue
method, instead of the id of the new created block.fixes #5971