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

handleCaretClick does not work on custom caret #320

Closed
antpngl92 opened this issue Mar 13, 2023 · 1 comment
Closed

handleCaretClick does not work on custom caret #320

antpngl92 opened this issue Mar 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@antpngl92
Copy link

antpngl92 commented Mar 13, 2023

Version

  • Vue: 3.2.37
  • multiselect: 2.5.8
  • nuxt: 3.0.0

Description

When I try to use custom caret the handleCaretClick does not work.

    <template #caret>
        <span
          aria-hidden="true"
          @click="handleCaretClick"
        >
          <nuxt-icon
            :name="`arrow_down${isSortBy() ? '_small' : ''}`"
            :class="[
              {'dropdown-single-select__icon--up': multiselect?.isOpen}
            ]"
          />
        </span>
      </template>
<script setup lang="ts">
const multiselect = ref<MultiselectRef>();
const handleCaretClick = ref();

onMounted(() => {
  handleCaretClick.value = (multiselect.value as any)?.handleCaretClick
});
</script>

It opens and closes the options list immediately. If I hold the button (mouseDown) the list stays open, as soon as I release it (mouseUp) the list closes.

@antpngl92 antpngl92 changed the title handleCaretClick does not work on custom carret handleCaretClick does not work on custom caret Mar 13, 2023
@adamberecz adamberecz added the bug Something isn't working label Oct 6, 2023
@adamberecz
Copy link
Collaborator

The default caret has pointer-events: none when the dropdown is closed. In the upcoming release handleCaretClick and isOpen params are added to the slot's scope. If you want to replicate the same behaviour, you can do:

<template #caret="{ handleCaretClick, isOpen }">
  <span
    aria-hidden="true"
    @click="handleCaretClick"
    :style="{
      pointerEvents: isOpen ? 'auto' : 'none'
    }"
  >
    x
  </span>
</template>

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

2 participants