File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import React , { type ReactNode } from "react" ;
1+ import React , { type ReactNode , useRef } from "react" ;
22
33import styles from "./App.module.css" ;
44import Rounds from "./Rounds" ;
@@ -28,6 +28,8 @@ export default function App() {
2828 const [ state , dispatch ] = useAppState ( ) ;
2929 useLoadData ( dispatch ) ;
3030
31+ const guessInputRef = useRef < HTMLInputElement | null > ( null ) ;
32+
3133 switch ( state . phase ) {
3234 case "pre-game" : {
3335 if ( state . wordPack == null ) {
@@ -55,6 +57,7 @@ export default function App() {
5557 >
5658 < label className = { `${ styles . guessLabel } centered-container flex-col` } >
5759 < input
60+ ref = { guessInputRef }
5861 type = "text"
5962 autoFocus
6063 className = { `${ styles . guess } word` }
@@ -66,7 +69,12 @@ export default function App() {
6669 < div > Unscramble the word!</ div >
6770 </ label >
6871 < div className = { `${ styles . buttonRow } centered-container flex-row` } >
69- < button onClick = { ( ) => dispatch ( { type : "skip-word" } ) } >
72+ < button
73+ onClick = { ( ) => {
74+ dispatch ( { type : "skip-word" } ) ;
75+ guessInputRef . current ?. focus ( ) ;
76+ } }
77+ >
7078 Skip
7179 </ button >
7280 < button onClick = { ( ) => dispatch ( { type : "end-game" } ) } >
You can’t perform that action at this time.
0 commit comments