Skip to content

Commit b9800f1

Browse files
committed
fix: additional fixes
1 parent 3ba946f commit b9800f1

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

flashcards/public/student-ui.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6361,7 +6361,7 @@ function Np({ title: e, flashcards: n, styling: t }) {
63616361
}
63626362
}, [r, u, h]), !u)
63636363
return /* @__PURE__ */ M.jsxs("div", { className: "flashcards_block", children: [
6364-
/* @__PURE__ */ M.jsxs("div", { className: "fc-number", "aria-label": "Flashcard counter", role: "status", children: [
6364+
/* @__PURE__ */ M.jsxs("div", { className: "fc-number", "aria-label": "Flashcard counter", children: [
63656365
"0 / ",
63666366
/* @__PURE__ */ M.jsx("span", { className: "fc-total", children: g.length })
63676367
] }),
@@ -6400,7 +6400,7 @@ function Np({ title: e, flashcards: n, styling: t }) {
64006400
] });
64016401
const N = g[r];
64026402
return /* @__PURE__ */ M.jsxs("div", { className: "flashcards_block", children: [
6403-
/* @__PURE__ */ M.jsxs("div", { className: "fc-number", "aria-label": "Flashcard counter", role: "status", children: [
6403+
/* @__PURE__ */ M.jsxs("div", { className: "fc-number", "aria-label": "Flashcard counter", children: [
64046404
/* @__PURE__ */ M.jsx("span", { className: "current-fc", children: r + 1 }),
64056405
" / ",
64066406
/* @__PURE__ */ M.jsx("span", { className: "fc-total", children: g.length })
@@ -6444,6 +6444,8 @@ function Np({ title: e, flashcards: n, styling: t }) {
64446444
"div",
64456445
{
64466446
className: "fc-card-front",
6447+
"aria-hidden": o,
6448+
inert: o ? "" : void 0,
64476449
style: {
64486450
borderColor: t.borderColor,
64496451
backgroundColor: t.backgroundColor
@@ -6469,6 +6471,8 @@ function Np({ title: e, flashcards: n, styling: t }) {
64696471
"div",
64706472
{
64716473
className: "fc-card-back",
6474+
"aria-hidden": !o,
6475+
inert: o ? void 0 : "",
64726476
style: {
64736477
borderColor: t.borderColor,
64746478
backgroundColor: t.backgroundColor

frontend/src/react-inert.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference types="react" />
2+
3+
declare module 'react' {
4+
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
5+
inert?: string;
6+
}
7+
}
8+
9+
export {};

frontend/src/student-ui/student-ui.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('StudentUi', () => {
7070
await userEvent.click(screen.getByRole('button', { name: 'Start flashcard deck' }));
7171

7272
screen.getByText('Question 1');
73-
const counter1 = screen.getByRole('status', { name: 'Flashcard counter' });
73+
const counter1 = screen.getByLabelText('Flashcard counter');
7474
expect(counter1?.textContent).toBe('1 / 3');
7575

7676
const prevBtn = screen.getByRole('button', { name: 'Previous card' });
@@ -82,7 +82,7 @@ describe('StudentUi', () => {
8282

8383
await userEvent.click(nextBtn);
8484
expect(screen.getByText('Question 2')).toBeInTheDocument();
85-
const counter2 = screen.getByRole('status', { name: 'Flashcard counter' });
85+
const counter2 = screen.getByLabelText('Flashcard counter');
8686
expect(counter2?.textContent).toBe('2 / 3');
8787

8888
// Both buttons should be enabled on middle card
@@ -91,7 +91,7 @@ describe('StudentUi', () => {
9191

9292
await userEvent.click(nextBtn);
9393
expect(screen.getByText('Question 3')).toBeInTheDocument();
94-
const counter3 = screen.getByRole('status', { name: 'Flashcard counter' });
94+
const counter3 = screen.getByLabelText('Flashcard counter');
9595
expect(counter3?.textContent).toBe('3 / 3');
9696

9797
// Next button should be disabled on last card
@@ -100,7 +100,7 @@ describe('StudentUi', () => {
100100

101101
await userEvent.click(prevBtn);
102102
expect(screen.getByText('Question 2')).toBeInTheDocument();
103-
const counter4 = screen.getByRole('status', { name: 'Flashcard counter' });
103+
const counter4 = screen.getByLabelText('Flashcard counter');
104104
expect(counter4?.textContent).toBe('2 / 3');
105105
});
106106

frontend/src/student-ui/student-ui.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function StudentUi({ title, flashcards, styling }: StudentUiProps) {
124124
if (!isStarted) {
125125
return (
126126
<div className="flashcards_block">
127-
<div className="fc-number" aria-label="Flashcard counter" role="status">
127+
<div className="fc-number" aria-label="Flashcard counter">
128128
0 / <span className="fc-total">{shuffledFlashcards.length}</span>
129129
</div>
130130
<div
@@ -159,7 +159,7 @@ function StudentUi({ title, flashcards, styling }: StudentUiProps) {
159159

160160
return (
161161
<div className="flashcards_block">
162-
<div className="fc-number" aria-label="Flashcard counter" role="status">
162+
<div className="fc-number" aria-label="Flashcard counter">
163163
<span className="current-fc">{currentIndex + 1}</span> / <span className="fc-total">{shuffledFlashcards.length}</span>
164164
</div>
165165
<div
@@ -198,6 +198,8 @@ function StudentUi({ title, flashcards, styling }: StudentUiProps) {
198198
>
199199
<div
200200
className="fc-card-front"
201+
aria-hidden={isFlipped}
202+
inert={isFlipped ? '' : undefined}
201203
style={{
202204
borderColor: styling.borderColor,
203205
backgroundColor: styling.backgroundColor,
@@ -219,6 +221,8 @@ function StudentUi({ title, flashcards, styling }: StudentUiProps) {
219221
</div>
220222
<div
221223
className="fc-card-back"
224+
aria-hidden={!isFlipped}
225+
inert={!isFlipped ? '' : undefined}
222226
style={{
223227
borderColor: styling.borderColor,
224228
backgroundColor: styling.backgroundColor,

frontend/src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference types="vite/client" />
2+
/// <reference path="./react-inert.d.ts" />
23
declare let $: JQueryStatic;
34

45
type Flashcard = {

0 commit comments

Comments
 (0)