Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
82 stars 9 forks source link

Modal throws error "unexpected tag <undefined> in <ui-modal>" when text nodes used in modal #272

Closed hsdonkin closed 5 months ago

hsdonkin commented 5 months ago

Describe the bug

When you implement <ui-modal> with children with no outerHTML, the modal throws an error and fails to load

To Reproduce

<ui-modal id="my-modal">
  Hello world
  <ui-title-bar title="Title">
    <button variant="primary">Label</button>
    <button onclick="document.getElementById('my-modal').hide()">Label</button>
  </ui-title-bar>
</ui-modal>

Expected behaviour

Text nodes should be rendered in the modal

Contextual information

App bridge loaded via admin dashboard

Additional context

Remix app

charlesdobson commented 5 months ago

Hi @hsdonkin, this is actually by design as we look for an element node to copy over the content. We only support 1 main child element (with whatever content you want within it). So, for your example, using <p>Hello world</p> or <span>Hello world</span> would be the way to go.