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

Provide version that's Vue 3 compatible

Open sinner opened this issue 4 years ago • 36 comments

It Doesn't have compatibility with the Vue 3 beta version. When the plugin is loaded it throws an error:

  • Uncaught TypeError: Vue.extend is not a function

sinner avatar May 14 '20 18:05 sinner

Yeah. This is a Vue 2 plugin. I'll release a vue 3 compatible version in time.

LinusBorg avatar May 14 '20 19:05 LinusBorg

Sidenote: Depending on your usecase you might not need portal-vue anymore as Vue 3 has a basic Portal in core now, named <teleport />.

https://github.com/vuejs/rfcs/blob/master/active-rfcs/0025-teleport.md

LinusBorg avatar May 15 '20 07:05 LinusBorg

@LinusBorg

Sidenote: Depending on your usecase you might not need portal-vue anymore as Vue 3 has a basic Portal in core now, named <teleport />.

https://github.com/vuejs/rfcs/blob/master/active-rfcs/0025-teleport.md

Will you still provide a vue3 compatible version, or users wanting v3 will need to migrate code to teleport ? Would you kindly provide a migration guide?

mariusa avatar Jul 01 '20 10:07 mariusa

I'll provide a Vue 3 compatible version, as <teleport> doesn't offer everything that portal-vue does - but the former has none of the caveats/downsides of the latter as well.

So people who can use <teleport> for their usecase should do so.

LinusBorg avatar Jul 01 '20 13:07 LinusBorg

@LinusBorg teleport can't work with transition, this cause some transition(leave animate) broken.

yoyoys avatar Jul 23 '20 06:07 yoyoys

Instead of duplicating the effort, improving teleport would be better instead of porting portal-vue to vue3? Or maybe have teleport plugins.

As a developer, I'd also want one component which works well enough, instead of several, each having various downsides.

mariusa avatar Jul 23 '20 07:07 mariusa

Teleport is already designed to solve the 80% use case, not all of Portal-Vue. If that covers your needs, by all means use that.

Portal-Vue does a few more things that teleport doesn't, so if you need those 20%, use Portal-Vue.

As those 20% of additional use cases make up for 80% of portal-vue's weight, those will not make it into core.

I'll try and build the new version on top of teleport so there's no duplication going on.

LinusBorg avatar Jul 23 '20 19:07 LinusBorg

@LinusBorg teleport can't work with transition, this cause some transition(leave animate) broken.

That should.be addressed as a bug in the Vue 3 repo then.

LinusBorg avatar Jul 23 '20 19:07 LinusBorg

@LinusBorg teleport can't work with transition, this cause some transition(leave animate) broken.

That should.be addressed as a bug in the Vue 3 repo then.

I think this is not only a bug, because teleport is DOM-based, it could not send any component to transition child, bug portal-target can be a good target.

@LinusBorg I'll try and build the new version on top of teleport so there's no duplication going on.

but this is a good idea :)

yoyoys avatar Jul 24 '20 08:07 yoyoys

because teleport is DOM-based, it could not send any component to transition child,

I'm not sure what you mean here.

I again suggest to try and open an issue about your problem in the Vue 3 Repo. I can tell you that I would expect this to work - and I wrote the RFC for <teleport>.

LinusBorg avatar Jul 24 '20 08:07 LinusBorg

Hi, do you have an exact plan for release a version for vue 3 ? And what is about performance for vue 3 version , i see the lack of performance by vue 2 version. And i think about the consistent name with vue's teleport like teleport-slot , maybe is easier for developers to understand. I think it is better if your full version can be intergrated in core, because the vue 3 has tree shaking .So the developers don't need to worry about the bundle size, and the core team can maintain it better. I see the big value by your plugin to decouple the code in some cases like widget or cms system. Maybe you can write a RFC to persuade the core team .

anhoev avatar Jul 28 '20 09:07 anhoev

Following/joining, I have an issue with the portal target living as a sibling of the portal (portal sends content of the selected article to the sidebar), which isn't supported by teleport:

https://github.com/vuejs/vue-next/issues/992#issuecomment-616126089

The target element cannot be a part of the same component... It needs to be outside of <div id="app">.

https://github.com/vuejs/vue-next/issues/1705#issuecomment-663849543

[Vue warn]: Failed to locate Teleport target with selector ".cell2". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.

I'm pretty sure I could use some hacking to force vue to render the sidebar and then in the nextTick populate the articles so the teleport target exists before an article, but I'd rather the portal handle waiting an extra render cycle as this one does.

loren138 avatar Jul 30 '20 14:07 loren138

any update ?

gigasource avatar Sep 18 '20 10:09 gigasource

On it but got set back a bit as I broke my arm recently. coding is .... difficult right now ^^

Will def still be a few more weeks before I can publish something.

LinusBorg avatar Sep 18 '20 14:09 LinusBorg

Sorry to hear that. Get well soon.

joorce avatar Sep 18 '20 17:09 joorce

So, I'm well enough recovered to start working on the migration. It's going well so far, I'm a few missing tests away from udpating documentation.

If everythign goes as planned (which, let's be honest, it rarely does) I'll have a preview release ready sometime next week.

LinusBorg avatar Nov 02 '20 13:11 LinusBorg

Things of course go slower, but code and tests are now fully ported.

Left: Update docs, document breaking changes (few) and publish.

LinusBorg avatar Nov 08 '20 12:11 LinusBorg

Sorry for bloating the thread, but I really wanted to point how examplary your communication is @LinusBorg - keeping everyone updated on the matter! Very few keep their users updated like this (and often leave you hanging for a long time until a big boom happens - if it ever does...). Inspiring!

cjblomqvist avatar Nov 16 '20 14:11 cjblomqvist

Oh I often fail at that as well :D

LinusBorg avatar Nov 16 '20 14:11 LinusBorg

@LinusBorg I hope you're feeling better. Do you have an eta on this? I've tried using the new teleport feature of v3 but it seems you can only use it outside of the Vue DOM. Portal doesn't seem to have that limitation. Is that correct?

ashbryant avatar Nov 20 '20 12:11 ashbryant

@LinusBorg Is there any progress on this issue?

ps73 avatar Jan 27 '21 08:01 ps73

Yes, though it took longer than anticipated.

I have an alpha version ready, just need to publish. Preliminary docs are already up at https://next.portal-vue.linusb.org

I'm in the middle of preparing a talk, so will release the alpha on sunday after that. Can't take distractions right now.

LinusBorg avatar Jan 27 '21 10:01 LinusBorg

Missed my personal deadline for this weekend but I'll squeeze it in somewhere in the coming days.

LinusBorg avatar Feb 02 '21 12:02 LinusBorg

@LinusBorg Sorry to bump this, have you had any time to look at this?

pertoyra avatar Feb 15 '21 08:02 pertoyra

silently published 3.0.0-alpha.0 in the next tag, feel free to check it out.

I'll do an announcement later.

Docs are preliminary and still need some work here and there, but the bulk should be usable.

LinusBorg avatar Feb 25 '21 13:02 LinusBorg

Currently i am trying to migrate a vue2 project to vue3, first i tried to use teleport, but i need the @change and :order functionality. so i found this one. But now i am getting: [Vue warn]: inject() can only be used inside setup() or functional components. I use vue: 3.1.1 with vue-cli and not vite

The example from this repo works fine.

Botz avatar Jun 19 '21 19:06 Botz

@Botz Can you share any more details? With what you provided it's hard to check if/how this is related to this library/version.

If so, Please open a bug issue.

LinusBorg avatar Jun 20 '21 08:06 LinusBorg

@LinusBorg I have the opposite issue with the "node" version, I'm stuck in node 12 and the plugins is requiring node 14. Is there a technical reason for it?

tochoromero avatar Aug 03 '21 19:08 tochoromero

@LinusBorg I dug through the Vue 3 version a little. In the wormhole code, it looks like an entirely separate Vue app is being created. Is there a way to wormhole content within the consuming app? That would preserve things like global components and directives that users register and expect to still work when they pass them through the wormhole.

ghost avatar Sep 29 '21 21:09 ghost

I'm not sure what you are talking about exactly. There's no app being created.

LinusBorg avatar Sep 30 '21 06:09 LinusBorg

@LinusBorg A call to createApp happens in the mountPortalTarget utility method. If users want to programmatically wormhole content to document.body or insert it as a child of #app and still have directives and global components work properly, how is that possible without explicitly mounting <portal-target>? A good example use case would be building a library with a ToastManager and an app calling ToastManager.open(ToastComponent, { ...managerOptions}). Ideally such a manager would automatically mount a <portal-target> in the same app so that the toast content inherits global configuration, directives, etc. It would be nice to not require the app to explicitly import and mount a <portal-target> that's just going to be stuck on document.body.

micDropper avatar Sep 30 '21 17:09 micDropper

Oh, you are talking about that edge case where one might want to use portal-vue instead of <teleport>? That indeed uses a separate app instance, yes.

We could likely make the new instance share the current app's components and directives as well - we already do it for the provide's. Feel free to open a feature request as a reminder for me.

LinusBorg avatar Sep 30 '21 19:09 LinusBorg

Thanks a lot @LinusBorg , though teleport is built now in vue 3, I was stuck when using inertia with laravel. I was using persistent layout and wanted to have multiple slots in parent so children can inject whatever they want. As for now there is no support for multiple slots when using persistent layout in inertia. Also teleport could not make it happen for me as it was made for scenarios where we would like to teleport content outside of the App hierarchy but somewhere else in the DOM. So your alpha version of portal-vue sort it out for me. Many thanks.

yannbanvi avatar Mar 11 '22 06:03 yannbanvi

Thanks a lot @LinusBorg , though teleport is built now in vue 3, I was stuck when using inertia with laravel. I was using persistent layout and wanted to have multiple slots in parent so children can inject whatever they want. As for now there is no support for multiple slots when using persistent layout in inertia. Also teleport could not make it happen for me as it was made for scenarios where we would like to teleport content outside of the App hierarchy but somewhere else in the DOM. So your alpha version of portal-vue sort it out for me. Many thanks.

Having the same issue this alpha package made it super easy! Many thanks for the vue3 update

whitespacecode avatar May 17 '22 08:05 whitespacecode

FYI there is another Vue 3 effort here:

https://github.com/VasekProchazka/vue3-portal

jaredthirsk avatar Jun 28 '22 05:06 jaredthirsk

Installing version 3.0.0-beta.0 works fine for me

Can be installed using next tag btw

timyourivh avatar Aug 02 '22 12:08 timyourivh