GithubHelp home page GithubHelp logo

Comments (14)

SimoTod avatar SimoTod commented on June 3, 2024 1

Thanks @tonysm
I switched from turbo:load to turbo:render because of #29
A few people needed it (I wasn't too sure because I was a bit worried something else would break and... Here we are, hahha). I assume turno:render runs too early and the browser hasn't run the livewire javascript yet (which injects the $wire helper in alpine) since it's in the body. Probably we just need to wait a frame, I'll double check this week

from alpine-turbo-drive-adapter.

SimoTod avatar SimoTod commented on June 3, 2024 1

Closing for now as I'm not planning to support v1. Please reopen if it's still an issue with v2 and Alpine 2

from alpine-turbo-drive-adapter.

SimoTod avatar SimoTod commented on June 3, 2024

Hi @tonysm ,i need to have a look. $wire is a property defined in livewire and injected in Alpine at runtime but it's not part of the core and I have never tried the adapter with Livewire. I'll keep you posted.

P.s. Depending on your use case, Alpine would work ok with Turbo without the adapter so you might not need it but Alpine tends to break in some specific edge cases (they are more or less mentioned in the changelog)

from alpine-turbo-drive-adapter.

SimoTod avatar SimoTod commented on June 3, 2024

Hi @tonysm

unfortunately, I wasn't able to replicate the issue. I tried with a vanilla installation, then I've also tried your app (after re-adding the adapter) and I couldn't see the error. Can you send me some instructions to replicate please?

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

Uhm, weird. Trying it one more time over here. Will also give it a try on a new install.

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

Uhm. It happens when opening the Jetstream pages (team settings, profile).

from alpine-turbo-drive-adapter.

SimoTod avatar SimoTod commented on June 3, 2024

Cool, I'll give it a go. Does it happen when I visit the page or do I have to click something specific?

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

uhm, interesting. The last version that works for me is 1.0.1. The other ones fail because of the arrow function being used in the [x-cloak] handling. And after that the 1.1.0 fails here.

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

@SimoTod it happens when you go from one page to one of the Jetstream pages, not if you refresh straight on that page.

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

OK, so I think the issue has to do with Livewire's entangle and Turbo.

image

Based on what I tried here, when you use entangle, the component gets evaluated to window.Livewire.find({COMPONENT_ID}).entangle() and that does not seem to work nicely with Turbo when you are visiting a page that uses this.

Laravel Jetstream's modal uses entangle (source).

The issue only happens when navigating to a page that has a Livewire component using entangle from another page (from / to /second via the menu in the demo below).

I don't think pushState has anything to do with this (as it also happens in private windows the first time you visit the second page, so there is no "cached page").

Got a simpler demo with the issue working here: https://github.com/tonysm/livewire-alpine-turbo-entangle-issue/blob/main/app/Http/Livewire/Counter.php#L22

I tried without the adapter and it works well. I tried with version 1.0.4 and it works well. So I think it has to do with something in 1.1.0.

I don't know exactly where the issue is at right now but will keep digging next weekend.

from alpine-turbo-drive-adapter.

 avatar commented on June 3, 2024

OK, so I think the issue has to do with Livewire's entangle and Turbo.

image

Based on what I tried here, when you use entangle, the component gets evaluated to window.Livewire.find({COMPONENT_ID}).entangle() and that does not seem to work nicely with Turbo when you are visiting a page that uses this.

Laravel Jetstream's modal uses entangle (source).

The issue only happens when navigating to a page that has a Livewire component using entangle from another page (from / to /second via the menu in the demo below).

I don't think pushState has anything to do with this (as it also happens in private windows the first time you visit the second page, so there is no "cached page").

Got a simpler demo with the issue working here: https://github.com/tonysm/livewire-alpine-turbo-entangle-issue/blob/main/app/Http/Livewire/Counter.php#L22

I tried without the adapter and it works well. I tried with version 1.0.4 and it works well. So I think it has to do with something in 1.1.0.

I don't know exactly where the issue is at right now but will keep digging next weekend.

I am not even using alpine-turbo-drive-adapter package in a livewire app with turbo and I am getting the same error. So It has to do something with livewire and turbo.
@entangle is a laravel blade wrapper around $wire which gets injected by livewire into alpine component

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

I've tried this on a fresh Laravel install with Jetstream. Without the adapter navigating to a page that uses entangle works. It only breaks after adding the Alpine adapter.

@SimoTod so the issue you mentioned that made you change from turbo:load to turbo:render was because elements using alpine could be returned from a non-422 response and those were not working?

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

@SimoTod yep, I changed the turbo:render to turbo:load in the bundled JS file and the entangle just works. That seems to be the issue.

It sounds like an upstream bug in Turbo.js, no? As I see it, it should dispatch the turbo:load when it receives a 422 response with an HTML body. Otherwise it will replace the page, but no event will be dispatched. I'm trying to see if I can reproduce it there.

from alpine-turbo-drive-adapter.

tonysm avatar tonysm commented on June 3, 2024

I've created an issue in the Turbo.js repository (see the last reference above). After reading the issue again, I have a "workaround" in mind. We could hook into the Blade parsing and append a Stimulus controller to elements that have x-data or x-init on them, this Stimulus controller would boot alpine on that element.

Would require using Stimulus, though. 😢

from alpine-turbo-drive-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.