Overview

When a component is added or removed from the component library when not inside the code editor, its underlying code and configuration are not retained. Instead, the component appears empty causing the component code and configuration being lost.

Proposed resolution

User interface changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lauriii created an issue. See original summary.

lauriii’s picture

Title: Adding component to component library results in component code and configuration being lost » Adding/removing component to component library outside of code editor results in component code and configuration being lost
Issue summary: View changes
balintbrews’s picture

Title: Adding/removing component to component library outside of code editor results in component code and configuration being lost » [PP-1] Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version
Status: Active » Postponed
Related issues: +#3508140: PATCH request for config entities reset values that are not sent

I took a look, and what happens here is that if we use the contextual menu from the sidebar list, we will send the canonical entity data with the PATCH request when we update the JavaScriptComponent entity to rename it or make it internal/exposed, because that's what we have available in the React component that outputs that list. With a new code component which hasn't been published since it was created, it means that only the auto-saved version has the data — and we lose all of that. 🙈

This isn't a cache invalidation problem, because the endpoint that lists the code components doesn't use auto-saved data. To solve the issue, we need to:

  1. Fix #3508140: PATCH request for config entities reset values that are not sent (priority increased)
  2. Update our PATCH requests to include only the wanted changes:
    • ui/src/features/code-editor/dialogs/AddToComponentsDialog.tsx
    • ui/src/features/code-editor/dialogs/RemoveFromComponentsDialog.tsx
    • ui/src/features/code-editor/dialogs/RenameCodeComponentDialog.tsx

The alternative would be to retrieve fresh auto-saved data if it exists before performing those actions, but I believe our efforts are better spent with making sure our API endpoint can properly handle PATCH requests, so we don't need any extra logic and complexity to handle this in the client.

wim leers’s picture

Title: [PP-1] Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version » Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version
Status: Postponed » Active
nagwani’s picture

Issue tags: +sprint
hooroomoo’s picture

Assigned: Unassigned » hooroomoo

hooroomoo’s picture

Seeing some strange behavior after adding a code component to the library, the JS doesn't load...

effulgentsia’s picture

Title: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version » [PP-1] Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version
Status: Active » Postponed
Related issues: +#3519634: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it

This issue surfaced #3519634: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it which I think the rest of the stuff that's here is blocked on until that's resolved.

wim leers’s picture

Title: [PP-1] Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version » Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version
Status: Postponed » Active
wim leers’s picture

Title: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version » [PP-1] Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version
Status: Active » Postponed
wim leers’s picture

Status: Postponed » Needs review
Issue tags: +Needs manual testing, +Usability
hooroomoo’s picture

StatusFileSize
new122.7 KB

#12. Thanks, I applied your MR 937 from #3519634: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it and it fixes the issue reported in the issue summary and it shows the current auto-saved JS and CSS when I open the code editor for the component.

But when I add the component to the layout page preview, the CSS isn't there. The CSS file for the component inside of /sites/default/astro-island never gets created.

missing css

wim leers’s picture

Status: Needs review » Postponed (maintainer needs more info)

#13: What are the steps to reproduce that? Is that reproducible:

  • on HEAD
  • with only this MR
  • with only #3519634's MR
  • only by having both this MR + #3519634's MR applied

?

IOW: is it safe to merge #3519634, or does that somehow introduce the problem you're describing? If so, we're lacking some tests, because #3519634: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it is passing tests. 😅

hooroomoo’s picture

Steps to reproduce:

1. Checkout this MR https://git.drupalcode.org/project/experience_builder/-/merge_requests/906. This MR contains frontend changes to only include desired changes in the PATCH requests AND #3519634's MR from yesterday.

2. Create a new code component
3. Make any change to the JS or CSS.
4. Click "Add to components" using the top right button in the code editor (NOT from the contextual menu)
5. After Adding it to components, the compiled JS and CSS file doesn't get generated in /sites/default/files/astro-island. When you click Add to components, the expected behavior is those files gets generated in that directory.

wim leers’s picture

In step 3, that's the code component's CSS and JS, not the global CSS, right? Because #3508937: Global AssetLibrary should render with its auto-saved state (if any) when rendered in the XB UI is a known bug.

hooroomoo’s picture

Correct, step 3 - Make any change to the code component's JS or CSS.

wim leers’s picture

Title: [PP-1] Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version » Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version
Status: Postponed (maintainer needs more info) » Needs work
hooroomoo’s picture

Status: Needs work » Closed (outdated)
hooroomoo’s picture

Assigned: hooroomoo » Unassigned

hooroomoo changed the visibility of the branch 3513147-using-actions-from to hidden.

hooroomoo’s picture

Status: Closed (outdated) » Fixed

Status: Fixed » Closed (fixed)

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

effulgentsia’s picture

Issue tags: -sprint