From d3a6cb2343a8691536ab44617f534b4eb615bbdd Mon Sep 17 00:00:00 2001
From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com>
Date: Wed, 16 Sep 2026 11:20:32 +0200
Subject: [PATCH] fix(teams): redirect team switches to the dashboard
---
app/Livewire/SwitchTeam.php | 10 ++--------
resources/views/livewire/switch-team.blade.php | 4 ++--
tests/Feature/SwitchTeamTest.php | 5 +++--
3 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/app/Livewire/SwitchTeam.php b/app/Livewire/SwitchTeam.php
index d50f57c141..3df399b100 100644
--- a/app/Livewire/SwitchTeam.php
+++ b/app/Livewire/SwitchTeam.php
@@ -19,7 +19,7 @@ class SwitchTeam extends Component
$this->switch_to($this->selectedTeamId);
}
- public function switch_to($team_id, ?string $currentUrl = null)
+ public function switch_to($team_id)
{
if (! auth()->user()->teams->contains($team_id)) {
return;
@@ -30,12 +30,6 @@ class SwitchTeam extends Component
}
refreshSession($team_to_switch_to);
- $parsedUrl = parse_url($currentUrl ?? '/dashboard');
- $redirectUrl = data_get($parsedUrl, 'path', '/dashboard');
- if ($query = data_get($parsedUrl, 'query')) {
- $redirectUrl .= '?'.$query;
- }
-
- return redirect($redirectUrl);
+ return redirect()->route('dashboard');
}
}
diff --git a/resources/views/livewire/switch-team.blade.php b/resources/views/livewire/switch-team.blade.php
index fb429e24f4..31ea8d3086 100644
--- a/resources/views/livewire/switch-team.blade.php
+++ b/resources/views/livewire/switch-team.blade.php
@@ -22,7 +22,7 @@
Teams
@foreach (auth()->user()->teams as $team)
-
@@ -66,7 +66,7 @@
Teams
@foreach (auth()->user()->teams as $team)
-
diff --git a/tests/Feature/SwitchTeamTest.php b/tests/Feature/SwitchTeamTest.php
index 9c4724939a..62439be510 100644
--- a/tests/Feature/SwitchTeamTest.php
+++ b/tests/Feature/SwitchTeamTest.php
@@ -21,12 +21,13 @@ beforeEach(function () {
session(['currentTeam' => $this->currentTeam]);
});
-test('switching teams keeps the current page URL', function () {
+test('switching teams always redirects to the dashboard', function () {
$currentUrl = route('security.api-tokens', ['page' => 2]);
Livewire::test(SwitchTeam::class)
+ ->assertDontSee('window.location.href', false)
->call('switch_to', $this->otherTeam->id, $currentUrl)
- ->assertRedirect($currentUrl);
+ ->assertRedirect(route('dashboard'));
expect(session('currentTeam')->is($this->otherTeam))->toBeTrue();
});