Skip to content

Commit b7c06d1

Browse files
authored
fix(blind mode): Extra letters in blind mode causing caret problems (@Leonabcd123) (monkeytypegame#7254)
### Description - Enable blind mode - Write extra letters - Caret will jump to above the first letter in the word
1 parent 36b59ae commit b7c06d1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

frontend/src/ts/utils/caret.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,16 @@ export class Caret {
297297
// we also clamp the letterIndex to be within the range of actual letters
298298
// anything beyond just goes to the edge of the word
299299
let side: "beforeLetter" | "afterLetter" = "beforeLetter";
300-
if (
301-
options.letterIndex >= letters.length ||
302-
(Config.blindMode && options.letterIndex >= wordText.length)
303-
) {
300+
if (options.letterIndex >= letters.length) {
304301
side = "afterLetter";
305-
options.letterIndex = letters.length - 1;
302+
303+
if (Config.blindMode) {
304+
options.letterIndex = wordText?.length - 1;
305+
} else {
306+
options.letterIndex = letters.length - 1;
307+
}
306308
}
309+
307310
if (options.letterIndex < 0) {
308311
options.letterIndex = 0;
309312
}

0 commit comments

Comments
 (0)