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

LPD-37782 Editor config contributor client extensions are re-applied when creating new Rich Text repeatable fields #4463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function loadEditorClientExtensions({
})
),
onLoad: (bindingContexts) => {
let transformedConfig = config;
let transformedConfig = JSON.parse(JSON.stringify(config));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The intended behavior we were going for is that the CXs modification to editor config is a local change. Original editor configuration, a controlled variable, should remain in it's original form. But because we are making an assignment here, changes leak to initial config object. @dsanz your intuition was right on this one! The shallow copy is also not good enough, as it would leak changes (JS 🤗 ) . We need to do a deep copy here. cc @thektan

The issue still remains that deep in parent framework config object changes on actions that should not really change it, such as focus on the field. This causes re-initialization of the whole editor, when it really doesn't need to. Improving this could be difficult, and is ultimately in the domain of product team. Because of this, I didn't revert the solution we did in #4430. This is the glitchy behavior if we do the revert on top of this PR:

vokoscreenNG-2024-10-03_15-31-58.mp4

⚠️ Although solution after this PR behaves nice and covers existing cases, there is a hidden problem: if original configuration legitimately changes, through some future action in UI, CXs will not be re-applied. I believe this is something that would be impossible for us to fix. If such a scenario appears, we will need to revert solution in 4430, and (1) live with glitchy behavior or (2) refactor parent framework to update config object only in some cases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see.... assignment makes 2 variables pointing to the same thing. One of the variables mutates the value.


bindingContexts.forEach(
({binding: editorTransformer, error}) => {
Expand Down