portal-vue icon indicating copy to clipboard operation
portal-vue copied to clipboard

Overlay with Portal with multiple trigger buttons on the same page

Open danielschweiger opened this issue 3 years ago • 3 comments
trafficstars

I have this component

<template>
    <div>
        <div class="my-2">
...
            <button class="rounded-full py-1 px-2 text-xs bg-90 text-white" @click="openModal">{{__('Open Modal')}}</button>
            <portal to="modals">
                <transition name="fade">
                    <general-modal
                        v-if="modalOpen"
                        @confirm="confirmModal"
                        @close="closeModal"
                    />
                </transition>
            </portal>
        </div>
    </div>
</template>

This component renders in a table row, so multiple times.

When I have just one tablerow, it works. When I have multiple table rows it works only on the last row.

How can I solve this?

danielschweiger avatar Nov 25 '21 10:11 danielschweiger

Not sure if this is still an issue for you as this issue is 2 months old.

What does it mean to say "it only works on the last row"?

LinusBorg avatar Jan 15 '22 11:01 LinusBorg

@LinusBorg I think what he is trying to do is to teleport multiple elements to the same target, as it is possible with Vue3's teleport feature: https://v3.vuejs.org/guide/teleport.html#using-multiple-teleports-on-the-same-target

I have also not managed to do that yet, only the last portal ends up being rendered in portal-target

andre-brdoch avatar Jan 17 '22 16:01 andre-brdoch

actually found out that this is possible by setting multiple key:

<PortalTarget name='nav-dropdown' multiple></PortalTarget>

andre-brdoch avatar Jan 17 '22 16:01 andre-brdoch