2

I've got a v-select inside a v-list-item-title. I need to stop click propagation on the v-list-item-title when I click on the v-select. I hardly try (like using v-on:click.stop but without success.

Here's the vuejs template :

<v-list v-show="showItems" dense class="transition-fast-in-fast-out">
    <v-list-group no-action sub-group :value="!isCopropriete">
        <template v-slot:activator>
            <v-list-item-title>
                <v-icon class="mr-2">mdi-account-multiple-plus</v-icon> GROUPEMENT INTERET
                <v-select
                    v-on:change="changeFoyerGroupementInteretSelected()"
                    v-on:click.stop
                    v-model="idGrcFoyerGroupementInteretSelected"
                    :items="mapFoyersGroupementInteret"
                    item-value="idFoyerGrc"
                    class="d-inline-flex mx-2"
                    style="width: 70px; font-size: 0.8125rem !important;"
                    height="29"
                    background-color="white"
                    dense
                    outlined
                    hide-details
                >
                    <template slot="selection" slot-scope="data">
                        {{ data.item.id}} / {{nbFoyersGroupementInteret}}
                    </template>
                    <template slot="item" slot-scope="data">
                        {{ data.item.id}} / {{nbFoyersGroupementInteret}}
                    </template>
                </v-select>
                ({{ foyerGroupementInteretSelected.nbPersonnesFiltered }}/{{ foyerGroupementInteretSelected.nbPersonnes }})
            </v-list-item-title>
        </template>
        <v-list-item v-for="(personne, indexPersonne) in getListePersonnesFiltered(foyerGroupementInteretSelected)" :key="indexPersonne" class="pl-8">
            <v-list-item-content class="py-0 my-0" @click="">
                <v-list-item-title>
                    <v-tooltip text top>
                        <template v-slot:activator="scope">
                            <v-btn :color="computePersonColorType(foyerGroupementInteretSelected.cdCategorieFoyer)" @click="displayModifierRole(personne, foyerGroupementInteretSelected.refExtFoyer)" x-small outlined v-on="scope.on">
                                {{ personne.codeRoleFoyer }}
                            </v-btn>
                        </template>
                        <span><v-icon x-small color="white">mdi-pencil</v-icon> Modifier le rôle de {{ personne.prenom }} {{ personne.nom }}</span>
                    </v-tooltip>
                    <v-btn text small @click="afficherClient(personne.idGrc)" class="text-capitalize">
                        {{ personne.prenom }} {{ personne.nom }} {{ getInfosAge(personne) }}<span v-if="isPM && personne.indicBeneficiaireEffectif "> - (BE)</span>
                    </v-btn>
                    <v-tooltip left v-if="isPM && personne.indicBeneficiaireEffectif">
                        <template v-slot:activator="scope">
                            <v-btn rounded size="xx-small" icon color="black" dark v-on="scope.on"><v-icon>mdi-information-outline</v-icon></v-btn>
                        </template>
                        <span>
                            <b>Le bénéficiaire effectif (BE)</b> est la personne physique <br />
                            contrôlant l’entreprise par différents moyens : <br />
                            - soit en détenant 25% des parts sociales <br />
                            ou des droits de votes au sein de l’entreprise ; <br />
                            - soit en ayant le contrôle sur les organes de gestion, <br />
                            d’administration ou de direction (Conseil d’Administration, Assemblée Générale, etc.).
                        </span>
                    </v-tooltip>
                </v-list-item-title>
            </v-list-item-content>
            <v-list-item-action class="my-0">
                <v-row no-gutters>
                    <v-btn v-if="isPM && showBEAddAction(personne)" class="mr-2 mt-1" outlined small color="primary" @click="openAjouterBeneficiairePopin(personne, foyerGroupementInteretSelected)">
                        <v-icon data-autom="bePersonneEnv_Btn" color="primary">mdi-plus</v-icon>BE
                    </v-btn>
                    <v-btn text small rounded icon @click="displayConfirmation(personne.idGrc, foyerGroupementInteretSelected.refExtFoyer, indexFoyer, indexPersonne)">
                        <v-icon data-autom="deletePersonneEnv_Btn" color="primary">mdi-delete-outline</v-icon>
                    </v-btn>
                </v-row>
            </v-list-item-action>
        </v-list-item>
    </v-list-group>
</v-list>

The result looks like this :

enter image description here

And when I click on the v-select, it also click on the v-list-item-title. I need to stop this action on the title when I click on the v-select.

EDIT : A working Solution for me is :

<v-select v-on:change="changeFoyerGroupementInteretSelected()"
    v-on:click.native.stop="changeFoyerGroupementInteretSelected()"
    v-model="idGrcFoyerGroupementInteretSelected"
    :items="mapFoyersGroupementInteret"
    item-value="idFoyerGrc"
    class="d-inline-flex mx-2"
    style="width: 70px; font-size: .8125rem !important;"
    height="29"
    background-color='white'
    dense outlined hide-details>

    <template slot="selection" slot-scope="data">
        {{ data.item.id}} / {{nbFoyersGroupementInteret}}
    </template>
    <template slot="item" slot-scope="data">
        {{ data.item.id}} / {{nbFoyersGroupementInteret}}
    </template>
</v-select>
5
  • 1
    Set v-on:click.stop on v-select should work fine. See jsfiddle.net/wnj4mk2f. Commented Dec 14, 2020 at 14:29
  • yes I try this, but it didn't work for me, so I'm looking for another way. Commented Dec 14, 2020 at 14:44
  • I'd like to help. Could you fork and edit my fiddle to reproduce your problem? Commented Dec 14, 2020 at 16:44
  • And what is the version of Vuetify you are using? Commented Dec 14, 2020 at 16:52
  • The fact is that I can't see any difference between the fiddle and my code. I'm in Vue.js v2.6.7 Commented Dec 15, 2020 at 9:17

1 Answer 1

1

I think your click call must be like that : v-on:click.native.stop="yourFunctionName"

Sign up to request clarification or add additional context in comments.

4 Comments

I've tried several mix thanks to you and @user:2438933, and the one who is working for me is : v-on:change="changeFoyerGroupementInteretSelected()" v-on:click.native.stop="" v-on:click="changeFoyerGroupementInteretSelected()"
in fact a solution with v-on:change and v-on:click.native.stop is working fine, just need to add () inside your proposal : v-on:change="changeFoyerGroupementInteretSelected()" v-on:click.native.stop="changeFoyerGroupementInteretSelected()"
Happy to hear that you solved your problem, Good Luck.
native.stop is now deprecated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.