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

SelectMenu with empty value #898

Closed
kicaj opened this issue Nov 1, 2023 · 6 comments
Closed

SelectMenu with empty value #898

kicaj opened this issue Nov 1, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@kicaj
Copy link

kicaj commented Nov 1, 2023

Environment

  • Node version: v18.18.2
  • Nuxt version: 3.8.0

Version

v2.10.0

Reproduction

https://stackblitz.com/edit/nuxt-ui-xmeysw?file=app.vue

Description

During the creating SelectMenu component with one of options is empty value, like below:

<USelectMenu :options="[ '', 'A1', 'A2', ..., 'Native' ]" placeholder="Level..." />
  • empty option is without height, height is just sum of padding values;
    Set &nbsp; is helpful
  • when select empty value, height of SelectMenu is just sum of padding values;
    Set value like above is helpful
  • why color of placeholder text is other then color of placeholder of Input component, by default?
image

Additional context

No response

Logs

No response

@kicaj kicaj added the bug Something isn't working label Nov 1, 2023
Copy link
Member

This is the normal behaviour, what would you expect to see instead? You can use the #option slot to display what you want: https://ui.nuxt.com/forms/select-menu#option

@aloky
Copy link

aloky commented Nov 22, 2023

@benjamincanac how add in options clear button?

@aloky
Copy link

aloky commented Nov 22, 2023

@connerblanton If i use multiple, how add clear button in option list?

@connerblanton
Copy link
Contributor

@aloky I don't believe you can add a clear button in the option list, but you can add a clear button on the SelectMenu by doing something like this:

<template>
  <UContainer class="min-h-screen flex items-center">
    <USelectMenu multiple v-model="selected" :options="people">
      <UInput
        class="flex-1 cursor-pointer"
        placeholder="Select people"
        :value="selected.length ? selected.join(', ') : ''"
        :ui="{ icon: { trailing: { pointer: '' } } }"
        readonly
      >
        <template #trailing>
          <UButton v-show="selected.length > 0" icon="i-heroicons-x-mark" @click.stop="selected = []" :padded="false" color="gray" variant="ghost" />
        </template>
      </UInput>
    </USelectMenu>
  </UContainer>
</template>

<script setup>
const people = ['Wade Cooper', 'Arlene Mccoy', 'Devon Webb', 'Tom Cook', 'Tanya Fox', 'Hellen Schmidt', 'Caroline Schultz', 'Mason Heaney', 'Claudie Smitham', 'Emil Schaefer']

const selected = ref([])
</script>

There's also more info about it in #246

@aloky
Copy link

aloky commented Nov 23, 2023

I don't believe you can add a clear button in the option list

@connerblanton maybe add option header slot?

@kicaj
Copy link
Author

kicaj commented Jun 11, 2024

This is the normal behaviour, what would you expect to see instead? You can use the #option slot to display what you want: https://ui.nuxt.com/forms/select-menu#option

I think, it should be has the same height, like options below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants