F
Filament9mo ago
Hugo

Theme doesn't apply on dashboard page

Hello, im having some odd interaction with filament and themes. My theme is applying and has been applying well since v2. Every page applies the correct
--primary
--primary
color, but for some reason when I get to the dashboard page, the
--primary
--primary
color changes back to filament's default one. Has anyone had the same issue or does anyone have a possible solution to this problem?
No description
No description
6 Replies
Dennis Koch
Dennis Koch9mo ago
Did you set the colors via ->colors() on the Panel provider?
Hugo
HugoOP9mo ago
Hello, yes I did.
No description
Hugo
HugoOP9mo ago
It is only happening when im in the Dashboard, in any other page or resource it applies the primary color that was set. In the dashboard it defaults to using filament's default primary color.
Dennis Koch
Dennis Koch9mo ago
Hm. That sounds really weird.
Hugo
HugoOP9mo ago
Indeed, I have no clue why this happened all of a sudden. Found the issue. I was redirecting users on their first login ever to the profile page and the ones that had login before to the dashboard page. This was applying the default filament styles. This fixes the issue I had with filament styles but now I don't have an asnwer for the solution I implemented for users to be redirected because using the route
->name('filament.admin.pages.dashboard')
->name('filament.admin.pages.dashboard')
will just apply the filament's default styles. This is what was causing the issue.
// Route::get('/admin', function () {
// $user = auth()->user();
// if ($user && $user->last_login_at === null) {
// return redirect("admin/profile");
// }

// return app(Dashboard::class)();
// })->name('filament.admin.pages.dashboard');
// Route::get('/admin', function () {
// $user = auth()->user();
// if ($user && $user->last_login_at === null) {
// return redirect("admin/profile");
// }

// return app(Dashboard::class)();
// })->name('filament.admin.pages.dashboard');
If anyone has any clue how can i still make this route work without having to change the styles, ill glady appreaciate. Using
->name(Dashboard::getRouteName())
->name(Dashboard::getRouteName())
has the same result Solved this issue aswell. For anyone that goes through the same, in order to manage where to redirect the user after login, I had a customFilamentLogin class set on
->login(CustomFilamentLogin::class)
->login(CustomFilamentLogin::class)
. In this class I overwrote the authenticate method to update the last_login_at column and I also then created a CustomLoginResponse:class extending filament's LoginResponse and I overwrote the toResponse method and just managed where the user should be redirected to
public function toResponse($request): RedirectResponse | Redirector
{
$user = auth()->user();
if ($user && $user->last_login_at === null) {
return redirect("admin/profile");
}

return redirect()->intended(Filament::getUrl());
}
public function toResponse($request): RedirectResponse | Redirector
{
$user = auth()->user();
if ($user && $user->last_login_at === null) {
return redirect("admin/profile");
}

return redirect()->intended(Filament::getUrl());
}
Dennis Koch
Dennis Koch9mo ago
Glad you figured this out. Still weird that the redirect messes with the config 🤔
Want results from more Discord servers?
Add your server