Unable to display notifications in admin panel
Hi! I'm struggling with showing notifications in the admin panel. I followed the docs which described that the notifications should already be implemented within the panel. For a custom page I added the
@livewire('notifications')
line to the Blade template and used the Notification::make()
as described in the documentation. According to the debugbar the view for a notification is indeed rendered, see the snippet below. But for some reason not visible, does someone have a solution? Thanks in advance!38 Replies
If you're using the admin panel already, there's no need for
@livewire('notifications')
, please share some code to allow us to help solve your problemAll rights thanks for your reply! Will remove this. The use is a form submit for which we want to provide a warning notification when nothing is found following the given search criteria. Like this:
Thanks in advance!
You're using a Filament Custom Page, or a Livewire Component? Cause there's no
submit()
hookIt's a Filament custom page that implements
HasForms
how's your blade file looks like?
hmm everything looks correct, have you tried removing
empty($this->content)
just to make sure?Yes I did, also tried some debugging with
dd()
in the same if-statement, which executed as expected.that's odd :/ sorry i really don't know what's happening, i have a similar code that works as expected
since you are using a custom form, you should do this:
share the whole code
I know, I just hide my actual code in the function as it didn't seem relevant for the issue. Notice the
// Get the content
line in which place this is performed correctly.share the whole code..
It doesn't matter, I just changed it to the following and it still doesn't work.
@.tibiba do you have
Broadcasting
enabled on your filament config?
to receive real-time notifications ...I thought broadcasting was only relevant for socket connections?
yeah, it is, just though about that because of the
echo.blade.php
view being loaded, if that was the case, it would require you to ->toBroadcast()
the notification
but that's not your case thenI understand, but I'm not using any socket connection in this project.
please try
see if the notification appears
This works! But how...?
is your page reloading when you save the form? (it shouldnt)
btw i suggest you to replace your
<form>
and <button>
with:
It doesn't
Will do, I followed the Filament docs for this.
yeah, the docs are for people outside filament admin, when you're using admin you can reuse ui components to keep consistency and avoid breaking ui on future updates
I didn't know, thank you very much!
tbh, idk
i don't think its a bug because its working for me, but maybe @Dan Harrin could help you
it doesn't make sense to not work there
this really shouldnt work lol
livewire cant dispatch browser events from mount()...
i dont have any ideas why flash notifications dont work
LOL
even with
parent::mount()
? after the parent mount shouldn't the component be fully mounted on screen?it shouldnt work lol
So I have something working that shouldn't but something that should doesn't? lol
Will try to figure this out, thanks for all the help!
good luck
Hi @.tibiba , did you manage to find a solution for your problem? I am facing the same issue. I just need to display a message when saving an item.
Unfortunately I did not. My best hope is to switch to v3 somewhere the following days and hope for it to work, otherwise I will dive into this again.
Thank you for your reply!
honestly i dont think its a filament problem
so no clue if that will even fix it
for me, notifications did not show from the beginning. not sure I did something wrong
not being rude here, but probably?
I haven't had many reports about this
yes, yes, not saying you are rude. Just saying I have no clue as well
have you tried in a new project?
also, are you using the admin panel with a resource?
or are you writing the notification code yourself
did not try with a new project. I am using it with a resource
and it also works for me if I send the notification in mounted
I managed to fix this. The issue was that my session was not persistent
Illuminate\Session\Middleware\StartSession:class had to be added in app/Http/Kernel.php
@.tibiba , maybe it helps you as well