Skip to content

Commit d8d33da

Browse files
committed
QoL
1 parent e7543a4 commit d8d33da

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/japanese/exercises/kana-typer/KanaTyper.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ const game = makeAutoObservable({
9595
clearInterval(this.timer.handle);
9696
this.timer = undefined;
9797
this.finished = true;
98+
setTimeout(
99+
() => document.getElementById("kana-typer-reset-button")?.focus(),
100+
1,
101+
);
98102
}
99103
},
100104

@@ -186,6 +190,7 @@ export function KanaTyper() {
186190
<br />
187191
<input
188192
autoFocus
193+
id="kana-typer-input"
189194
disabled={game.finished}
190195
value={game.currentInput}
191196
onKeyDown={(evt) => {
@@ -196,7 +201,15 @@ export function KanaTyper() {
196201
{game.finished && (
197202
<>
198203
<br />
199-
<button onClick={() => game.reset()}>Reset</button>
204+
<button
205+
id="kana-typer-reset-button"
206+
onClick={() => {
207+
game.reset();
208+
document.getElementById("kana-typer-input")?.focus();
209+
}}
210+
>
211+
Reset
212+
</button>
200213
<br />
201214
<div>
202215
Correct:{" "}

src/japanese/utils/kana-utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ function initDiacriticMaps() {
105105
}
106106

107107
const handakutenChars = [
108-
["ぱ ", "は"],
109-
["ぴ ", "ひ"],
110-
["ぷ ", "ふ"],
111-
["ぺ ", "へ"],
112-
["ぽ ", "ほ"],
108+
["ぱ", "は"],
109+
["ぴ", "ひ"],
110+
["ぷ", "ふ"],
111+
["ぺ", "へ"],
112+
["ぽ", "ほ"],
113113
];
114114
for (const [hiraganaDakuten, hiraganaNormal] of handakutenChars) {
115115
const katakanaDakuten = KanaUtils.toKatakana(hiraganaDakuten);

0 commit comments

Comments
 (0)