filament: Notification throws 500 error on admin panel

Package

filament/notifications

Package Version

v2.15.28

Laravel Version

v9.26.1

Livewire Version

v2.10.6

PHP Version

8.1.9

Problem description

In the filament admin panel when I save a new record or save an edited record the page will show me the saved notification for less than a second and after that, this error appears on my screen. image

Expected behavior

it must show the notification and not throw an error.

Steps to reproduce

  1. clone this repo: https://github.com/ariaieboy/filament-notification-bug-example
  2. copy .env.example file to .env
  3. create an SQLite database and set it on .env file
  4. run migration
  5. create filament user
  6. login to the admin panel
  7. try to create or edit a user

Reproduction repository

https://github.com/ariaieboy/filament-notification-bug-example

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (18 by maintainers)

Most upvoted comments

Can you fix that in your PR then? Please bump the version inside each package composer.json, not just the main composer.json

I don’t see why we would ever need to use Js::from() if we just bump the Livewire version?

Seems really weird that this was a patch release in livewire though.

Personally I would do it as Js:from() since v3 is so close and people will have to update their livewire anyway.

Probably because it was two different versions. I didn’t test it but my hunch is that if they were on the same version this wouldn’t have been an issue. Or there’s a bug in the @js directive with the version of livewire this example was locked to.

Yeah so this issue is caused by @js.

Recently, a fix was merged into Livewire to use the @js directive from Laravel instead of the one provided by Livewire if it’s available in the user’s Laravel version: https://github.com/livewire/livewire/pull/4876.

Previously, @js wouldn’t work in some places and we had to use {{ Js::from() }} instead. After that PR got merged, I updated the Filament notifications code to use the Blade directive instead of {{ Js::from() }}.

So anyone who’s using a Livewire version that predates the Livewire bug fix, will run into this Filament notifications issue. Reverting the following inside the notifications package fixes the issue:

- x-data="notificationComponent({ notification: @js($notification) })"
+ x-data="notificationComponent({ notification: {{ \Illuminate\Support\Js::from($notification) }} })"

@danharrin and @awcodes, do you think we should revert the @js change and use {{ Js::from() }} instead to be sure no one runs into issues like this one? Hard to test all usages of @js inside Filament and prevent any issues in the future. Personally, I’d say it was a bug in Livewire that has been fixed and users should just make sure to upgrade their Livewire version to include the bug fix.

Let me know your thoughts!

Is this really a Livewire issue, wow