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

[Vue][popover] Don't work on Nuxt and portalled is set to true by default #1450

Closed
Theo-Rige opened this issue Apr 27, 2024 · 1 comment
Closed

Comments

@Theo-Rige
Copy link

🐛 Bug report

In using Nuxt 3 and the popover seems to be portalled by default, contrary to what is stated in the documentation, and it doesn't work with the Vue 3 SFC example and portalled option explicitly set to false.

💥 Steps to reproduce

  1. Create a Nuxt 3 app
  2. Create a Popover.client.vue component by copy pasting the Vue SFC example from the doc
  3. Render it in app.vue
  4. See the popover component doesn't works

💻 Link to reproduction

CodeSandbox reproduction:

🧐 Expected behavior

The api.portalled be false by default and the popover works.

🌍 System information

Software Version(s)
Zag Version 0.48.0
Browser Edge 124.0.2478.67
Operating System Windows

📝 Additional information

image
image

@segunadebayo
Copy link
Member

Hi @Theo-Rige,

This is largely a documentation problem. Here's the snippet that should work:

<script setup>
  import * as popover from "@zag-js/popover"
  import { normalizeProps, useMachine } from "@zag-js/vue"
  import { computed, Teleport, Fragment } from "vue"

  const [state, send] = useMachine(popover.machine({ id: "1" }))
  const api = computed(() => popover.connect(state.value, send, normalizeProps))
</script>

<template>
  <div ref="ref">
    <button v-bind="api.triggerProps">Click me</button>
    <Teleport to="body" :disabled="!api.portalled">
      <div v-bind="api.positionerProps">
        <div v-bind="api.contentProps">
          <div v-bind="api.titleProps">Presenters</div>
          <div v-bind="api.descriptionProps">Description</div>
          <button>Action Button</button>
          <button v-bind="api.closeTriggerProps">X</button>
        </div>
      </div>
    </Teleport>
  </div>
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants