masmerise / livewire-toaster

Beautiful toast notifications for Laravel / Livewire.
MIT License
374 stars 22 forks source link

Redirect Livewire #4

Closed lucas-davi closed 1 year ago

lucas-davi commented 1 year ago

Hello guys

I'm trying use toast in redirect route livewire, but i'm getting this message:

image

Any ideas how to workaround this?

mabdullahsari commented 1 year ago

Can you provide the code block that's causing this issue?

You can use any other method in the meantime to dispatch your toasts.

mabdullahsari commented 1 year ago

Found the culprit. Please upgrade to 1.1.2.

lucas-davi commented 1 year ago

Hello, sorry for the delay responding.

I updated for the 1.1.2 version, the error message disappeared, but toast not displayed.

This is my code:

image

Thanks for the help!

mabdullahsari commented 1 year ago

Hello, sorry for the delay responding.

I updated for the 1.1.2 version, the error message disappeared, but toast not displayed.

This is my code:

image

Thanks for the help!

Can you show the contents of the Controller that's serving users.index?

zhi8617 commented 1 year ago

I am also facing the same issue... After redirecting, the Toast does not appear.

mabdullahsari commented 1 year ago

I am also facing the same issue... After redirecting, the Toast does not appear.

Okay. Can you please provide some more info in order to debug what's going on? Because I can't reproduce it.

mabdullahsari commented 1 year ago

I am also facing the same issue... After redirecting, the Toast does not appear.

More specifically, I'll need to see how you are dispatching your toasts and what your Controller / Livewire component you redirected to is doing in the next request. As I've said previously, I can't reproduce it alas and thus won't be able to provide a fix without a repro.

Thanks.

zhi8617 commented 1 year ago

https://gist.github.com/zhi8617/5d9cc0e17c5bb8d390d232d06c490916

I have placed the test code in the provided link.

The expected behavior of the code is that after executing the CompanyController, it should redirect to the test page and display a Toaster message.

Perhaps I misunderstood something?

Thank you for your response. I really appreciate the design of this package.

mabdullahsari commented 1 year ago

https://gist.github.com/zhi8617/5d9cc0e17c5bb8d390d232d06c490916

I have placed the test code in the provided link.

The expected behavior of the code is that after executing the CompanyController, it should redirect to the test page and display a Toaster message.

Perhaps I misunderstood something?

Thank you for your response. I really appreciate the design of this package.

Hey, thank you so much for the gist! I'll take a look as soon as possible.

mabdullahsari commented 1 year ago

So I had a gander, and everything seems to be fine.

Can you confirm whether your endpoints are using the web middleware group? And can you please share the contents of that middleware group also? I have a hunch that's going to be the culprit for both of you.

@zhi8617 @lucas-davi

Thanks!

zhi8617 commented 1 year ago

Thank you for your response. Yes, the endpoint uses web middleware, and the web middleware has not been modified.

Laravel Version 10.12.0 PHP Version 8.2.6

Executed within Laravel Sail.

zhi8617 commented 1 year ago

Perhaps I just encountered a special case. It's okay, go ahead and attend to your matters. Thank you.

mabdullahsari commented 1 year ago

Perhaps I just encountered a special case. It's okay, go ahead and attend to your matters. Thank you.

Hey,

I'll see if I can fix it. I did take a look yesterday and the culprit might be full-page Livewire components which is what you provided in the gist. I have never worked with full-page components, so I'll need a bit more time to figure out what's going wrong.

I'll keep you posted!

mabdullahsari commented 1 year ago

Hey @zhi8617

I set up an application with the exact setup you provided in the gist. Unfortunately I am still unable to reproduce the issue. I'd really appreciate a repository with minimal code that can reproduce the bug, so I can track down the cause and fix it. Could you provide such a repository?

Otherwise, my hands will be tied until some does provide a reproduction. Thanks.

zhi8617 commented 1 year ago

When I created a new Laravel application and it works, that's awesome! Thank you so much.

lucas-davi commented 1 year ago

Hello,

In my project I was also using the log-viewer extension.

I removed the log-viewer from the project and it worked perfectly as describe in the documentation.

Keeping the two extensions, after the redirect the Toast does not appear for me, is it possible a conflict between the extensions?

Thanks for the help! 😃

mabdullahsari commented 1 year ago

@lucas-davi Which version of that package did you install? I'll see if there's any conflict.

lucas-davi commented 1 year ago

I used these versions:

log-viewer: 2.4.1 toaster: 1.2.0

mabdullahsari commented 1 year ago

It was indeed a conflict of multiple packages registering a macro with the same name.

Please don't use the RedirectResponse / Redirector macros in this case and call the Toaster façade directly.