Skip to content

Commit 3a3e97a

Browse files
committed
fix(web): address review feedback on PoW challenge component
- Guard j() helper against null/empty textContent before JSON.parse - Use <button> instead of clickable <div> for "finished reading" control to support keyboard navigation and screen readers - Make currentLang a local const inside initTranslations since it is not read elsewhere Assisted-by: Claude Opus 4.6 via Claude Code Signed-off-by: Xe Iaso <me@xeiaso.net>
1 parent c112419 commit 3a3e97a

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

web/js/main.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ const j = (id: string): any | null => {
1515
return null;
1616
}
1717

18-
return JSON.parse(elem.textContent);
18+
const text = elem.textContent;
19+
if (text == null || text.trim() === "") {
20+
return null;
21+
}
22+
23+
return JSON.parse(text);
1924
};
2025

2126
const imageURL = (
@@ -66,11 +71,10 @@ const getRedirectUrl = () => {
6671
};
6772

6873
let translations: Record<string, string> = {};
69-
let currentLang: string;
7074

7175
// Initialize translations
7276
const initTranslations = async () => {
73-
currentLang = await getBrowserLanguage();
77+
const currentLang = await getBrowserLanguage();
7478
translations = await loadTranslations(currentLang);
7579
};
7680

@@ -281,7 +285,7 @@ function App({ anubisVersion, basePrefix }: AppProps) {
281285
)}
282286
</p>
283287
{phase === "reading" ? (
284-
<div
288+
<button
285289
id="progress"
286290
style={{
287291
display: "flex",
@@ -297,11 +301,14 @@ function App({ anubisVersion, basePrefix }: AppProps) {
297301
outlineOffset: "2px",
298302
width: "min(20rem, 90%)",
299303
margin: "1rem auto 2rem",
304+
border: "none",
305+
fontSize: "inherit",
306+
fontFamily: "inherit",
300307
}}
301308
onClick={() => redirectFn.current?.()}
302309
>
303310
{t("finished_reading")}
304-
</div>
311+
</button>
305312
) : (
306313
<div
307314
id="progress"

0 commit comments

Comments
 (0)