Overview

The component preview that generates a preview in real time for components when they are hovered isn't working for JS components.

Steps to reproduce:

  1. Create a JS component
  2. Go back to editing a page
  3. Hover over the component
  4. Confirm that there's no component preview visible on hover

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.

omkar-pd made their first commit to this issue’s fork.

omkar-pd’s picture

The component preview is now loading, but it appears empty. Debugging the issue.

wim leers’s picture

Title: Component preview not loading for JS components » Preview-on-hover in Component Library not loading for JS components
Component: Page builder » Theme builder
omkar-pd’s picture

StatusFileSize
new76.81 KB

I think the work on default_markup for code components is still pending.

default_markup: "@todo Make something 🆒 in https://www.drupal.org/project/experience_builder/issues/3498889" - Which appears to be fixed issue.

omkar-pd’s picture

Status: Active » Needs review
wim leers’s picture

Title: Preview-on-hover in Component Library not loading for JS components » Preview-on-hover in Component Library not loading for code components
Issue tags: +sprint-candidate

Updating title for consistent terminology.

Tagging per https://www.drupal.org/project/experience_builder/issues/3455753#release....

wim leers’s picture

Status: Needs review » Needs work
wim leers’s picture

#6: Good observation, but that's not responsible for the preview 😅

/xb/api/config/component does render preview markup for code components:

  "js.optional": {
    "source": "Code component",
    "metadata": {
      "slots": [
        
      ]
    },
    "field_data": {
      "maybe": {
        "required": false,
        "jsonSchema": {
          "type": "string"
        },
        "sourceType": "static:field_item:string",
        "value": null,
        "expression": "ℹ︎string␟value"
      }
    },
    "dynamic_prop_source_candidates": [
      
    ],
    "transforms": {
      "maybe": {
        "mainProperty": [
          
        ]
      }
    },
    "id": "js.optional",
    "name": "optional",
    "library": "primary_components",
    "category": "@todo",
    "default_markup": "<!-- xb-start-5b3715c6-9e10-4fa9-9692-732bfe366912 --><astro-island uid=\"5b3715c6-9e10-4fa9-9692-732bfe366912\"\n        component-url=\"/sites/default/files/astro-island/pKL_OwLDMlNxnBnBYIsn9BSu349KEpkBmq26qw_z8EQ.js\"\n        component-export=\"default\"\n        renderer-url=\"/modules/contrib/experience_builder/ui/lib/astro-hydration/dist/client.js\"\n        props=\"{}\"\n        ssr=\"\" client=\"only\"\n        opts=\"{&quot;name&quot;:&quot;optional&quot;,&quot;value&quot;:&quot;preact&quot;}\"><script type=\"module\" src=\"/modules/contrib/experience_builder/ui/lib/astro-hydration/dist/client.js\" blocking=\"render\"></script><script type=\"module\" src=\"/sites/default/files/astro-island/pKL_OwLDMlNxnBnBYIsn9BSu349KEpkBmq26qw_z8EQ.js\" blocking=\"render\"></script></astro-island><!-- xb-end-5b3715c6-9e10-4fa9-9692-732bfe366912 -->",
    "css": "<link rel=\"stylesheet\" media=\"all\" href=\"/sites/default/files/css/css_2L-jRULv7_xXe52gIO_bjqU3o7kiFhu1A3RE26luuI8.css?delta=0&amp;language=en&amp;theme=olivero&amp;include=eJxLrShILcpMzUtOjU8qzcxJSS3STywuKcqPzyzOScxL0csvKMnMz0vMAQBNxxA1\" />\n",
    "js_header": "",
    "js_footer": "<script src=\"/sites/default/files/js/js_62jyEDukuEKD8nfERQhtlwDsBadoEVzY0V2toERniis.js?scope=footer&amp;delta=0&amp;language=en&amp;theme=olivero&amp;include=eJxLrShILcpMzUtOjU8qzcxJSS3STywuKcrXy6hMKUosyczPAwDxxA3H\"></script>\n"
  },

Investigating…

wim leers’s picture

Assigned: Unassigned » wim leers
Issue tags: -sprint-candidate +sprint

Paired with @balintbrews — he gave me a hunch!

Note how the example in #10 does not include the import maps!

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Needs review
Related issues: +#3507567: Make JS files generated from code components import Preact modules with the correct paths
StatusFileSize
new83.43 KB

Bingo:

What was needed, is making #attached[import_maps] be respected not just when rendering a full HTML response, but also when rendering each individual component preview.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Per @hooroomoo's review — they manually tested it; it didn’t interfere with any click events for opening the menus which was their concern 🥳

omkar-pd’s picture

🙌🙌👏👏

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

  • wim leers committed b2c8b76d on 0.x authored by omkar-pd
    Issue #3508975 by wim leers, omkar-pd, hooroomoo, balintbrews: Preview-...
nagwani’s picture

Issue tags: -sprint

Status: Fixed » Closed (fixed)

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