nextcloud-libraries / nextcloud-vue

🍱 Vue.js components for Nextcloud app development ✌ https://npmjs.org/@nextcloud/vue
https://nextcloud-vue-components.netlify.app/
Other
214 stars 84 forks source link

[vue3] NcAppContent causes two `main` elements #6018

Open susnux opened 3 weeks ago

susnux commented 3 weeks ago

With Vue 2 the $mount will replace the DOM node with the app, but with Vue 3 the app is rendered within the node. This causes problem in most cases, as the templates user and public will render <main id="content"> and apps are supposed to mount like app.mount('#content').

This will cause a DOM like:

<main id="content">
    <div class="nc-content">
        <main id="app-content-vue"><!--- ---></main>
    </div>
</main>

This is invalid: https://html.spec.whatwg.org/multipage/grouping-content.html#the-main-element

A document must not have more than one main element that does not have the hidden attribute specified.

So we need adjust NcAppContent to div if mounted within a main tag (conditionally because the base and guest template do not provide a main element).

ShGKme commented 1 day ago

It is a bit more problematic.

Making NcAppContent a div instead of main solves the problem with main inside main. But it doesn't solve the root issue.

The structure should be

<div>
  <nav /> 
  <main />
  <aside />
</div>

... and not

<main>
  <nav /> 
  <div />
  <aside />
</div>
ShGKme commented 1 day ago

I think that it's better to go the opposite way.

Adjust layout.user.php to replace that root <main> with a <div>. Then it works fine in Vue 2 and Vue 3 apps without any changes in components.

It may require adjustments on non-Vue apps, but: