Skip to content

Commit

Permalink
[Fix] Allow unselecting Launch Options. Show selector after a game fi…
Browse files Browse the repository at this point in the history
…nishes installation (#3991)

Fix Launch Options selector not allowing to unselect options
  • Loading branch information
arielj authored Nov 17, 2024
1 parent 3eff5b1 commit cb8d5e8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/frontend/screens/Game/GamePage/components/LaunchOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -17,7 +17,7 @@ const LaunchOptions = ({ gameInfo, setLaunchArguments }: Props) => {

useEffect(() => {
window.api.getLaunchOptions(appName, runner).then(setLaunchOptions)
}, [])
}, [gameInfo])

if (!gameInfo.is_installed) {
return null
Expand All @@ -31,9 +31,14 @@ const LaunchOptions = ({ gameInfo, setLaunchArguments }: Props) => {
<SelectField
htmlId="launch_options"
onChange={({ target: { value } }) => {
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...')}
Expand Down

0 comments on commit cb8d5e8

Please sign in to comment.