From cecd08f3acb93bdb625bdec5d2a6e9150d1c19eb Mon Sep 17 00:00:00 2001 From: Pandipipas <62224708+Pandipipas@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:57:09 +0100 Subject: [PATCH] Fix scoreboard panel state resets across tabs --- .../components/ScoreboardPanel.vue | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/dashboard/scoreko-dev/components/ScoreboardPanel.vue b/src/dashboard/scoreko-dev/components/ScoreboardPanel.vue index c3c596f..24d79da 100644 --- a/src/dashboard/scoreko-dev/components/ScoreboardPanel.vue +++ b/src/dashboard/scoreko-dev/components/ScoreboardPanel.vue @@ -394,6 +394,9 @@ const onRightBlur = () => { const applyLeftPlayerData = (playerId: string) => { const player = playersStore.players[playerId]; + if (!player) { + return; + } scoreboardStore.scoreboard.leftTeamOverride = player?.team ?? ''; scoreboardStore.scoreboard.leftCountryOverride = player?.country ?? ''; leftCountryInput.value = getCountryLabel(scoreboardStore.scoreboard.leftCountryOverride); @@ -401,6 +404,9 @@ const applyLeftPlayerData = (playerId: string) => { const applyRightPlayerData = (playerId: string) => { const player = playersStore.players[playerId]; + if (!player) { + return; + } scoreboardStore.scoreboard.rightTeamOverride = player?.team ?? ''; scoreboardStore.scoreboard.rightCountryOverride = player?.country ?? ''; rightCountryInput.value = getCountryLabel(scoreboardStore.scoreboard.rightCountryOverride); @@ -662,9 +668,11 @@ watch( rightCharacterOptions.value = options; const allowed = new Set(options.map((option) => option.value)); const savedCharacters = newGame ? charactersByGame.value[newGame] : undefined; + const currentLeftCharacter = scoreboardStore.scoreboard.leftCharacter; + const currentRightCharacter = scoreboardStore.scoreboard.rightCharacter; - let nextLeftCharacter = savedCharacters?.leftCharacter ?? ''; - let nextRightCharacter = savedCharacters?.rightCharacter ?? ''; + let nextLeftCharacter = savedCharacters?.leftCharacter ?? currentLeftCharacter; + let nextRightCharacter = savedCharacters?.rightCharacter ?? currentRightCharacter; if (!allowed.has(nextLeftCharacter)) { nextLeftCharacter = ''; @@ -674,11 +682,15 @@ watch( nextRightCharacter = ''; } - if (!nextLeftCharacter && !nextRightCharacter) { + if ((!nextLeftCharacter || !nextRightCharacter) && (!currentLeftCharacter || !currentRightCharacter)) { const defaults = getDefaultCharactersByGame(newGame); if (defaults) { - nextLeftCharacter = allowed.has(defaults.leftCharacter) ? defaults.leftCharacter : ''; - nextRightCharacter = allowed.has(defaults.rightCharacter) ? defaults.rightCharacter : ''; + if (!nextLeftCharacter) { + nextLeftCharacter = allowed.has(defaults.leftCharacter) ? defaults.leftCharacter : ''; + } + if (!nextRightCharacter) { + nextRightCharacter = allowed.has(defaults.rightCharacter) ? defaults.rightCharacter : ''; + } } }