From 5bf049c361cb0711a62583c90f819da66eb8ac74 Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Tue, 3 Sep 2024 00:13:31 -0300 Subject: [PATCH] Fix Launch Options selector not allowing to unselect options --- .../Game/GamePage/components/LaunchOptions.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/frontend/screens/Game/GamePage/components/LaunchOptions.tsx b/src/frontend/screens/Game/GamePage/components/LaunchOptions.tsx index cfab8afc81..e381ec240c 100644 --- a/src/frontend/screens/Game/GamePage/components/LaunchOptions.tsx +++ b/src/frontend/screens/Game/GamePage/components/LaunchOptions.tsx @@ -6,7 +6,7 @@ import { SelectField } from 'frontend/components/UI' interface Props { gameInfo: GameInfo - setLaunchArguments: (selected_option: LaunchOption) => void + setLaunchArguments: (selected_option: LaunchOption | undefined) => void } const LaunchOptions = ({ gameInfo, setLaunchArguments }: Props) => { @@ -17,7 +17,7 @@ const LaunchOptions = ({ gameInfo, setLaunchArguments }: Props) => { useEffect(() => { window.api.getLaunchOptions(appName, runner).then(setLaunchOptions) - }, []) + }, [gameInfo]) if (!gameInfo.is_installed) { return null @@ -31,9 +31,14 @@ const LaunchOptions = ({ gameInfo, setLaunchArguments }: Props) => { { - const selectedIndex = Number(value) - setSelectedLaunchOptionIndex(selectedIndex) - setLaunchArguments(launchOptions[selectedIndex]) + if (value === '') { + setSelectedLaunchOptionIndex(-1) + setLaunchArguments(undefined) + } else { + const selectedIndex = Number(value) + setSelectedLaunchOptionIndex(selectedIndex) + setLaunchArguments(launchOptions[selectedIndex]) + } }} value={selectedLaunchOptionIndex.toString()} prompt={t('launch.options', 'Launch Options...')}