Overview

Steps to reproduce:

  1. Create a new component
  2. Right click component in the "Code" group
  3. Select "Add to components"
  4. You should be getting a 422 error now
The \u0027imported_js_components\u0027 field is required when \u0027source_code_js\u0027 or \u0027compiled_js\u0027 is provided

Proposed resolution

User interface changes

CommentFileSizeAuthor
CleanShot 2025-04-23 at 13.41.52.gif1.13 MBlauriii

Comments

lauriii created an issue. See original summary.

wim leers’s picture

This was definitely a bug while #3518185: Store imported JS components in `JavaScriptComponent` (and reflect in config dependencies) was in without #3518198: Set code component dependencies and support code editor preview based on import statements having landed.

It seems that Add to components has not yet taken advantage of #3508140: PATCH request for config entities reset values that are not sent, and is hence doing more than just setting status: true, because the error message literally says what's going on: compiled_js or source_code_js are being sent, which then also requires imported_js_components to be sent.

The UI should surface the validation errors provided by the server explicitly, instead of telling the user to look at the browser console, by doing #3503547: Display validation errors in dialogs that create sections.

hooroomoo’s picture

#3513147: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version is supposed to update the client PATCH requests to only include the wanted changes instead of also including the compiled/source_js in the request which I started on in this MR: https://git.drupalcode.org/project/experience_builder/-/merge_requests/9...

But currently doing that results in the component not working in the preview, I think due to something with the auto-save. I am hoping #3519634: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it will unblock #3513147: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version which would then fix this issue.

wim leers’s picture

hooroomoo’s picture

Status: Active » Fixed

#3519634: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it got merged which includes updating the client PATCH requests to only send what is necessary (therefore not triggering the error) which fixes this bug

wim leers’s picture

#5: 🥳 — I did see that in the diff, and was wondering about this :D

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.