BUGFIX: Player can switch tabs without losing focus on current work (#2724)

This commit is contained in:
catloversg
2026-05-07 05:11:30 +07:00
committed by GitHub
parent 4ee26edb85
commit 7c6d147ff7
4 changed files with 7 additions and 16 deletions
+7
View File
@@ -266,6 +266,13 @@ export function GameRoot(): React.ReactElement {
}
break;
}
// If the current page is Page.Work, the player is focusing on their current work. Switching to another page ends
// that focus, so we must call Player.stopFocusing() immediately after Router.toPage() to keep Player.focus in
// sync. Instead of repeating this logic wherever Router.toPage() is called, we should centralize the check and
// the Player.stopFocusing() call here.
if (pageWithContext.page === Page.Work && page !== Page.Work && Player.currentWork && Player.focus) {
Player.stopFocusing();
}
setNextPage({ page, ...context } as PageWithContext);
},
back: () => {
-6
View File
@@ -219,7 +219,6 @@ export function WorkInProgressRoot(): React.ReactElement {
},
unfocus: () => {
Router.toPage(Page.City);
Player.stopFocusing();
},
},
title: `You are attempting ${crime.workName}`,
@@ -266,7 +265,6 @@ export function WorkInProgressRoot(): React.ReactElement {
},
unfocus: () => {
Router.toPage(Page.Location, { location: Locations[classWork.location] });
Player.stopFocusing();
},
},
title: (
@@ -303,7 +301,6 @@ export function WorkInProgressRoot(): React.ReactElement {
},
unfocus: () => {
Router.toPage(Page.Terminal);
Player.stopFocusing();
},
},
title: (
@@ -334,7 +331,6 @@ export function WorkInProgressRoot(): React.ReactElement {
},
unfocus: () => {
Router.toPage(Page.Terminal);
Player.stopFocusing();
},
},
title: (
@@ -388,7 +384,6 @@ export function WorkInProgressRoot(): React.ReactElement {
},
unfocus: () => {
Router.toPage(Page.Faction, { faction });
Player.stopFocusing();
},
},
title: (
@@ -439,7 +434,6 @@ export function WorkInProgressRoot(): React.ReactElement {
Router.toPage(Page.Job);
},
unfocus: () => {
Player.stopFocusing();
Router.toPage(Page.Job);
},
},