nuxt / ui

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

CommandPalette triggers click event when closing modal #2117

Closed MickL closed 2 weeks ago

MickL commented 2 weeks ago

Environment

------------------------------
- Operating System: Darwin
- Node Version:     v21.6.1
- Nuxt Version:     3.13.0
- CLI Version:      3.13.1
- Nitro Version:    2.9.7
- Package Manager:  bun@1.1.26
- Builder:          -
- User Config:      extends, modules, future, experimental, runtimeConfig, scripts, i18n, routeRules, ignore, site, app, ogImage, sitemap, plausible
- Runtime Modules:  @nuxt/scripts@^0.6.4, @nuxtjs/seo@2.0.0-rc.19, @nuxtjs/tailwindcss@^6.12.0, @vee-validate/nuxt@^4.13.2, nuxt-og-image, @nuxtjs/plausible@^1.0.2
- Build Modules:    -
------------------------------

Version

2.8.14

Reproduction

-

Description

I have a simple command palette in a modal that displays Algolia search result:

<script setup lang="ts">
const searchIsOpen = ref(false);

function onSelectSearchResult(product) {
  searchIsOpen.value = false;
  navigateTo('/products/' + product.id);
}
</script>

<template>
<UModal
    v-model="searchIsOpen"
  >
    <UCommandPalette
      :groups
      :autoselect="false"
      @update:model-value="onSelectSearchResult"
    >
    <UButton
      icon="material-symbols-close-rounded"
      class="absolute top-2 right-2"
      @click="searchIsOpen = false"
    />
</UModal>
</template>

Unfortunately when clicking outside of the modal, or on the close button it always triggers onSelectSearchResult. So the user closes the modal but gets then redirect to a page he doesnt wanted to view.

Additional context

No response

Logs

No response

benjamincanac commented 2 weeks ago

Duplicate #1981 and #1708.