fix: auto-advance on new-game selections

Advance the wizard immediately when selecting game type, break rule, race-to quick picks, and completed break-order choices for a consistent tap-first flow.

Made-with: Cursor
This commit is contained in:
Frank Schwenk
2026-04-14 15:28:52 +02:00
parent ed7c6232c1
commit 55cba1495f
4 changed files with 16 additions and 2 deletions
@@ -27,10 +27,17 @@ export const BreakOrderStep = ({ players, rule, onNext, onCancel, initialFirst =
const handleFirst = (idx: number) => { const handleFirst = (idx: number) => {
setFirst(idx); setFirst(idx);
const isImmediateFlow = rule !== 'wechselbreak' || playerCount !== 3;
if (isImmediateFlow) {
onNext(idx);
}
}; };
const handleSecond = (idx: number) => { const handleSecond = (idx: number) => {
setSecond(idx); setSecond(idx);
if (rule === 'wechselbreak' && playerCount === 3 && first > 0) {
onNext(first, idx);
}
}; };
const handleSubmit = (e: Event) => { const handleSubmit = (e: Event) => {
@@ -16,6 +16,7 @@ export const BreakRuleStep = ({ onNext, onCancel, initialValue = 'winnerbreak' }
const handleSelect = (nextRule: BreakRule) => { const handleSelect = (nextRule: BreakRule) => {
setRule(nextRule); setRule(nextRule);
onNext(nextRule);
}; };
const handleSubmit = (e: Event) => { const handleSubmit = (e: Event) => {
@@ -16,6 +16,7 @@ export const GameTypeStep = ({ onNext, onCancel, initialValue = '' }: GameTypeSt
const handleSelect = (selectedType: string) => { const handleSelect = (selectedType: string) => {
setGameType(selectedType); setGameType(selectedType);
onNext(selectedType);
}; };
const handleSubmit = (e: Event) => { const handleSubmit = (e: Event) => {
@@ -23,6 +23,11 @@ export const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }: Ra
initialValue !== '' ? initialValue : defaultValue initialValue !== '' ? initialValue : defaultValue
); );
const toRaceToValue = (value: string | number) => {
if (value === RACE_TO_INFINITY || value === 'Infinity') return Infinity;
return parseInt(String(value), 10) || 0;
};
useEffect(() => { useEffect(() => {
if (initialValue === '' || initialValue === undefined) { if (initialValue === '' || initialValue === undefined) {
setRaceTo(defaultValue); setRaceTo(defaultValue);
@@ -34,6 +39,7 @@ export const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }: Ra
const handleQuickPick = (value: number | typeof RACE_TO_INFINITY) => { const handleQuickPick = (value: number | typeof RACE_TO_INFINITY) => {
const selected = value === RACE_TO_INFINITY ? RACE_TO_INFINITY : value; const selected = value === RACE_TO_INFINITY ? RACE_TO_INFINITY : value;
setRaceTo(selected); setRaceTo(selected);
onNext(toRaceToValue(selected));
}; };
const handleInputChange = (e: Event) => { const handleInputChange = (e: Event) => {
@@ -43,8 +49,7 @@ export const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }: Ra
const handleSubmit = (e: Event) => { const handleSubmit = (e: Event) => {
e.preventDefault(); e.preventDefault();
const raceToValue = raceTo === 'Infinity' ? Infinity : (parseInt(String(raceTo), 10) || 0); onNext(toRaceToValue(raceTo));
onNext(raceToValue);
}; };
return ( return (