File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
vanilla/guess-the-word/src/events/handlers Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 11import { setIsAlertInitialized } from "@/state/alert" ;
22import { showCorrectWord } from "@/ui/word" ;
33import { $hints , $hintsContent } from "@/ui/hints/elements" ;
4- import { $reset } from "@/ui/actions" ;
4+ import { $randomWord , $ reset } from "@/ui/actions" ;
55import { CLASSES } from "@/consts/css-classes" ;
66
77/** @param {Object } params
@@ -12,7 +12,8 @@ export function handleGameOver({ $currentField }) {
1212 GameAlert . show ( { color : "error" , text : "😔 Game Over!" } ) ;
1313 } ) ;
1414
15- showCorrectWord ( ) ;
15+ $randomWord . disabled = true ;
16+ showCorrectWord ( ) . then ( ( ) => ( $randomWord . disabled = false ) ) ;
1617
1718 $hints . classList . add ( CLASSES . HIDDEN ) ;
1819 $hintsContent . classList . add ( CLASSES . HIDDEN ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { hasCompletedAllDifficulties } from "@/utils/difficulty/completed";
77import { InsaneDifficulty } from "@/utils/difficulty/insane" ;
88import { showCorrectWord } from "@/ui/word" ;
99import { $hints , $hintsContent } from "@/ui/hints/elements" ;
10- import { $reset } from "@/ui/actions" ;
10+ import { $randomWord , $ reset } from "@/ui/actions" ;
1111import { CLASSES } from "@/consts/css-classes" ;
1212
1313export function handleGameSuccess ( ) {
@@ -16,7 +16,8 @@ export function handleGameSuccess() {
1616 GameAlert . show ( { color : "success" , text : "🎉 Success!" } ) ;
1717 } ) ;
1818
19- showCorrectWord ( ) ;
19+ $randomWord . disabled = true ;
20+ showCorrectWord ( ) . then ( ( ) => ( $randomWord . disabled = false ) ) ;
2021
2122 if ( InsaneDifficulty . isApplied ( ) )
2223 import ( "@/ui/insane-countdown-bar" ) . then ( ( { InsaneCountdownBar } ) =>
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ import { RESETS } from "@/consts/resets";
1919import { CLASSES } from "@/consts/css-classes" ;
2020
2121export async function generateRandomWord ( ) {
22- // FIX: disable random button while showing correct word
22+ // TODO: add auxiliary state to ensure that the button is disabled even if
23+ // manipulating the DOM
2324
2425 if ( words . length === 0 ) {
2526 import ( "./difficulty-complete" ) . then ( ( { handleDifficultyComplete } ) =>
You can’t perform that action at this time.
0 commit comments