nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
3.8k stars 464 forks source link

bug(UPopper): if any parent has a container query the popper gets yeeted #1351

Closed sandros94 closed 7 months ago

sandros94 commented 7 months ago

Environment

Version

v2.13.0

Reproduction

<template>
  <div class="not-prose @container/languages w-fit">
    <UDropdown :items="languages" :popper="{ arrow: true, placement:'top' }">
      <UButton
        :padded="false"
        class="rounded-full no-underline"
        icon="i-heroicons-language"
        size="2xl"
        variant="ghost"
      />
    </UDropdown>
  </div>
</template>

<script setup lang="ts">
import type { DropdownItem } from '#ui/types'

const languages: DropdownItem[][] = [
  [{ label: 'English' }],
  [{ label: 'Español' }],
  [{ label: 'Italiano' }],
]
</script>

Description

image

Sometimes images tells more than words...

Removing @container/languages or any other container query, from any parent, fixes the issue.

Additional context

No response

Logs

No response

sandros94 commented 7 months ago

This also happens with Popper

benjamincanac commented 7 months ago

Have you tried changing the strategy to absolute?

<template>
  <div class="not-prose @container/languages w-fit">
    <UDropdown :items="languages" :popper="{ arrow: true, placement:'top', strategy: 'absolute' }">
      <UButton
        :padded="false"
        class="rounded-full no-underline"
        icon="i-heroicons-language"
        size="2xl"
        variant="ghost"
      />
    </UDropdown>
  </div>
</template>

You might need to set a width through the ui prop.

sandros94 commented 7 months ago

I didn't know the strategy option and indeed that was it.

You might need to set a width through the ui prop.

With something like a button that already has a fixed size it seem not to be required (if you were talking about the dropdown's ui prop).