-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot append assets after Filament's unless using PackageServiceProvider
by Spatie
#12615
Comments
FilamentServiceProvider
's FilamentAsset::register()
PackageServiceProvider
by Spatie
We need to do that otherwise calls made to the facade BEFORE the singleton is registered get lost, since they are overridden by the singleton registration. |
Thanks, but I'm still confused as to why
Do you know what can be causing this? Is there a way to inject CSS after filament's? I have exhausted all means and the only way was to include it in my custom field's blade. |
So you have no problem injecting before Filament's, is there a reason you want it after? Specificity? |
Alright, there are 2 issues here
|
Will probably need some extra checks to see if the singleton has been resolved before registering another |
If I may, I do not think filament needs to have static methods in a facade to achieve its aims, removing them will make behavior more standardized and easier to debug. |
Removing them will cause breaking changes for asset registration in |
It's something we will look at dealing with in v4 but its not possible in v3. |
Yea, v4 is good enough for me. Thanks! |
Package
filament/filament
Package Version
v3.2.73
Laravel Version
10.48.10
Livewire Version
v3.4.12
PHP Version
8.1.28
Problem description
At the core of it, the problem is:
When filamentphp calls
\Filament\Support\Facades\FilamentAsset::register()
fromFilamentServiceProvider::packageBooted()
, it goes straight to thestatic register()
of the facadehttps://github.com/filamentphp/support/blob/49637c225f9eb72380a3dc54e9fd951563955770/src/Facades/FilamentAsset.php#L37
When my ServiceProvider calls
\Filament\Support\Facades\FilamentAsset::register()
, it goes to Laravel'sAliasLoader.php
and thenAssetManager::register()
https://github.com/filamentphp/support/blob/49637c225f9eb72380a3dc54e9fd951563955770/src/Assets/AssetManager.php#L46Why does the filamentphp call goes to the
static register()
which does not follow Laravel's convention? This leads to a very confusing code path that one cannot follow by just reading codeThis surfaced because I needed to override some CSS of easyMDE, so wanted to insert them after filament's by registering later, but was unable to do so despite trying several methods e.g
$this->booted(function() {...});
,static::resolved(function (AssetManager $assetManager)...
Expected behavior
There is probably some reason why
\Filament\Support\Facades\FilamentAsset::register()
exists, but it does not seem to follow Laravel convention. Thus, in my view:\Filament\Support\Facades\FilamentAsset::register()
should not existFilamentServiceProvider::packageBooted()
,\Filament\Support\Facades\FilamentAsset::register()
should callAssetManager::register()
Or it would greatly help if someone could clarify why things work as described in my problem description
Steps to reproduce
It happens in every repository that uses filament, just load any filament page after setting XDebug breakpoints at
Reproduction repository
n/a
Relevant log output
No response
The text was updated successfully, but these errors were encountered: