-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(InputMenu/SelectMenu): don't show ComboboxEmpty when loading is true #5956
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
base: v4
Are you sure you want to change the base?
Conversation
π WalkthroughWalkthroughThis change adds loading state handling to input menu and select menu components. Two example files bind the loading prop to their fetch status when pending. The core InputMenu and SelectMenu components are updated to conditionally hide their empty state during loading by adding Estimated code review effortπ― 1 (Trivial) | β±οΈ ~5 minutes π₯ Pre-merge checks | β 3β Passed checks (3 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
|
Would you mind sharing the code to reproduce this use-case? |
|
A little bit of context:
<script setup lang="ts">
const { data: users, status, execute } = await useAsyncData(
async () => {
await new Promise(resolve => setTimeout(resolve, 1000))
return $fetch('https://jsonplaceholder.typicode.com/users')
},
{
immediate: false,
transform: (data: any) => {
return data?.map(user => ({ id: user.id, label: user.name, avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` } }))
},
lazy: true
}
)
const open = ref(false)
watch(open, (value) => {
if (value) {
execute()
}
})
</script>
<template>
<USelectMenu v-model:open="open" :items="users" class="w-48" :loading="status === 'pending'" placeholder="Select user" />
</template>With this MR: Screen.Recording.2026-01-28.at.10.39.27.movAnd without Screen.Recording.2026-01-28.at.10.40.41.movMaybe even disable the search, when there are no items and loading is true? |
|
I'm not sure removing the ComboboxEmpty on loading is the right way, this solution displays a double border which doesn't look nice. How about using the <script setup lang="ts">
const { data: users, status, execute } = await useAsyncData(
async () => {
await new Promise(resolve => setTimeout(resolve, 1000))
return $fetch('https://jsonplaceholder.typicode.com/users')
},
{
immediate: false,
transform: (data: any) => {
return data?.map(user => ({ id: user.id, label: user.name, avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` } }))
},
lazy: true
}
)
const open = ref(false)
watch(open, (value) => {
if (value) {
execute()
}
})
</script>
<template>
<USelectMenu
v-model:open="open"
:items="users"
class="w-48"
placeholder="Select user"
:ui="{ empty: 'flex justify-center' }"
>
<template #empty>
<UIcon v-if="status === 'pending'" name="i-lucide-loader-circle" class="animate-spin size-5" />
</template>
</USelectMenu>
</template> |
π Linked issue
β Type of change
π Description
Screen.Recording.2026-01-27.at.12.19.32.mov
Currently, when there is no data but being fetched and you open the InputMenu for example the ComboboxEmpty displays and then after the data is displayed.
π Checklist