masmerise / livewire-toaster

Beautiful toast notifications for Laravel / Livewire.
MIT License
397 stars 23 forks source link

Toasts not showing when using navigate: true #44

Closed boptom closed 2 months ago

boptom commented 6 months ago

The problem: When using Livewire redirect with navigate: true along with @persist, the toasts do not show.

Toaster::success('Toast Message');

$this->redirect('/', navigate: true);

In layout:

@persist('toaster')
<x-toaster-hub />
@endpersist

Docs on navigation here: https://livewire.laravel.com/docs/navigate#redirects Possibly related to: https://github.com/masmerise/livewire-toaster/issues/28

What happens: The page navigates, but the toast does not show.

What is expected? The page navigates and the toast shows "Toast Message".

Why not use regular redirects? Previous toasts are not persisted and disappear on navigation with regular redirects from the backend.

Why use @persist? To persist the toast messages through navigation.

Laravel: 11.5.0 Livewire: 3.4.11

mabdullahsari commented 6 months ago

Hey, thanks for the in-depth explanation! I'll try taking a look at it today.

mabdullahsari commented 5 months ago

Hey! Unfortunately, I'm bereft of time lately and haven't had the opportunity to investigate what the root cause of this problem might be. I am most definitely welcoming pull requests that address this issue.

Thank you!

boptom commented 5 months ago

I'll give it another go when I have some time too. I'm not familiar with Laravel/Livewire internals and got lost following methods around last I tried.

I also couldn't figure out how to write a failing test for this. Any ideas?

mabdullahsari commented 5 months ago

I'll give it another go when I have some time too. I'm not familiar with Laravel/Livewire internals and got lost following methods around last I tried.

I also couldn't figure out how to write a failing test for this. Any ideas?

Hey, sorry for the late reply. You will most definitely need to set up Laravel Dusk for E2E testing since this is a visual hinderance which can only be observed on the browser.

mabdullahsari commented 2 months ago

Feel free to re-open this issue if you submit a PR in the near future!

mabdullahsari commented 1 week ago

This issue has been resolved with the latest release!