filament: Javascript error occurs after an action that displays a modal is run and the modal closes.

Package

filament/filament

Package Version

^2.13

Laravel Version

v9.11.0

Livewire Version

v2.5

PHP Version

PHP 8.0

Problem description

After an action that requires confirmation or displays a modal is run, and the modal closes, a javascript error occurs:

Alpine: Cannot reference "$wire" outside a Livewire component. Uncaught TypeError: wireEl is null

Expected behavior

The action completes and the modal closes without a Javascript error occurring

Steps to reproduce

  1. Login to Filament admin panel Demo online
  2. visit the edit page for any record/row in the brands page
  3. eg: https://demo.filamentphp.com/shop/brands/11/edit?activeRelationManager=0
  4. delete a related model on the relationship table eg: products relations table.
  5. open browser console
  • before confirming action:

Screenshot (33)

  • after confirming action:

Screenshot (32)

Reproduction repository

https://github.com/jojostx/filament-demo

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (24 by maintainers)

Most upvoted comments

@jojostx Seems like if you edit a record this occurs too.

image

This is happening on a project I am working on as well, in a similar case where a popup modal is shown on the RelationsManager.

Thanks

Hey, the fix was not reverted, we just didn’t need any of the code that handled closing modals any more. I can’t reproduce the problem myself any more? Please submit a new issue with a reproduction repository.

Turns out that setting __instance.property doesnt make an AJAX request, so the solution doesn’t work.

I swapped it out for __instance.set('property', null) which works fine

Alright. I am going to update my PR to @awcodes’s suggestion

But potentially it is a breaking change if we remove it…

@danharrin mentioned he had a potential fix ready locally. Let’s see what he’ll PR.

This has to be something in Alpine. $wire is available outside of $watch.