Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue3] NcAppContent causes two main elements #6018

Open
susnux opened this issue Aug 26, 2024 · 2 comments
Open

[vue3] NcAppContent causes two main elements #6018

susnux opened this issue Aug 26, 2024 · 2 comments
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working vue 3 Related to the vue 3 migration

Comments

@susnux
Copy link
Contributor

susnux commented Aug 26, 2024

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).

@susnux susnux added bug Something isn't working 1. to develop Accepted and waiting to be taken care of vue 3 Related to the vue 3 migration labels Aug 26, 2024
@ShGKme
Copy link
Contributor

ShGKme commented Sep 18, 2024

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
Copy link
Contributor

ShGKme commented Sep 18, 2024

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:

  • Having no main is not so bad as having main in main
  • It is better to always to it in app. We cannot say that a non-Vue app always has only the main content, and not navigation + main + sidebar. For example, the settings page. And if we consider the settings page valid, then we also can just remove <main> in <NcAppContent> at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working vue 3 Related to the vue 3 migration
Projects
None yet
Development

No branches or pull requests

2 participants