nuxt / ui

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

[Select] Incorrect z-index of select within modal #2347

Open EvertonWingert opened 15 hours ago

EvertonWingert commented 15 hours ago

Environment

Version

3.0.0-alpha.5

Reproduction

https://github.com/EvertonWingert/nuxtui-modal-select-issue

Description

When using a select inside a modal(slideover, drawer), the options list is rendered behind the modal content. This appears to be a z-index issue where the dropdown is not properly layered above the modal. Image

Additional context

<template>
  <UModal title="Modal with description" description="Lorem ipsum dolor sit amet, consectetur adipiscing elit.">
    <UButton label="Open" />

    <template #body>
      <USelectMenu v-model="value" :items="items" />
    </template>
  </UModal>
</template>
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

Logs

No response

Davounet commented 14 hours ago

I am having the same issue. It is tricky to fix, because since everything is teleported at the body root we can't use the stacking contexts.

EvertonWingert commented 7 hours ago

I managed to fix it using the following configuration

ui: {
    select: {
        slots: {
            content: 'z-50'
        }
    },
    selectMenu: {
        slots: {
            content: 'z-50'
        }
    }
}
benjamincanac commented 7 hours ago

Since the SelectMenu is in Modal which is portaled to the body, you might want to set :portal="false" on the SelectMenu.