Skip to content

Commit 42bf0a5

Browse files
committed
YKI(Frontend): Make pagination displayed rows label more mobile friendly
1 parent 3201151 commit 42bf0a5

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

frontend/packages/yki/public/i18n/en-GB/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
},
1818
"pagination": {
1919
"backButtonLabel": "Previous search results",
20-
"displayedRowsLabel": "Showing {{from}}-{{to}} / {{count}} results",
20+
"displayedRowsAriaLabel": "Showing {{from}}-{{to}} / {{count}} results",
21+
"displayedRowsLabel": "{{from}}-{{to}} / {{count}}",
2122
"nextButtonLabel": "Next search results",
2223
"rowsPerPage": "Results per page"
2324
}

frontend/packages/yki/public/i18n/fi-FI/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
},
1818
"pagination": {
1919
"backButtonLabel": "Edelliset hakutulokset",
20-
"displayedRowsLabel": "Näytetään {{from}}-{{to}} / {{count}} tulosta",
20+
"displayedRowsAriaLabel": "Näytetään {{from}}-{{to}} / {{count}} tulosta",
21+
"displayedRowsLabel": "{{from}}-{{to}} / {{count}}",
2122
"nextButtonLabel": "Seuraavat hakutulokset",
2223
"rowsPerPage": "Tulokset per sivu"
2324
}

frontend/packages/yki/public/i18n/sv-SE/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
},
1818
"pagination": {
1919
"backButtonLabel": "Tidigare sökresultat",
20-
"displayedRowsLabel": "Visas {{from}}-{{to}} / {{count}} resultat",
20+
"displayedRowsAriaLabel": "Visas {{from}}-{{to}} / {{count}} resultat",
21+
"displayedRowsLabel": "{{from}}-{{to}} / {{count}}",
2122
"nextButtonLabel": "Följande sökresultat",
2223
"rowsPerPage": "Resultat per sida"
2324
}

frontend/packages/yki/src/components/registration/examSession/PublicExamSessionListing.tsx

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Typography } from '@mui/material';
2-
import { LabelDisplayedRowsArgs } from '@mui/material/TablePagination';
32
import { Box } from '@mui/system';
4-
import { TFunction } from 'i18next';
53
import { useEffect, useRef } from 'react';
64
import {
75
CustomCircularProgress,
@@ -23,15 +21,35 @@ const getRowDetails = (examSession: ExamSession) => {
2321
return <PublicExamSessionListingRow examSession={examSession} />;
2422
};
2523

26-
const getDisplayedRowsLabel = (
27-
t: TFunction,
28-
{ from, to, count }: LabelDisplayedRowsArgs
29-
) => {
30-
return t('component.table.pagination.displayedRowsLabel', {
31-
from,
32-
to,
33-
count,
34-
});
24+
const DisplayedRowsLabel = ({
25+
from,
26+
to,
27+
count,
28+
}: {
29+
from: number;
30+
to: number;
31+
count: number;
32+
}) => {
33+
const translateCommon = useCommonTranslation();
34+
35+
return (
36+
<p
37+
aria-label={translateCommon(
38+
'component.table.pagination.displayedRowsAriaLabel',
39+
{
40+
from,
41+
to,
42+
count,
43+
}
44+
)}
45+
>
46+
{translateCommon('component.table.pagination.displayedRowsLabel', {
47+
from,
48+
to,
49+
count,
50+
})}
51+
</p>
52+
);
3553
};
3654

3755
export const PublicExamSessionsTable = ({
@@ -65,9 +83,9 @@ export const PublicExamSessionsTable = ({
6583
rowsPerPageLabel={translateCommon(
6684
'component.table.pagination.rowsPerPage'
6785
)}
68-
labelDisplayedRows={(args) =>
69-
getDisplayedRowsLabel(translateCommon, args)
70-
}
86+
labelDisplayedRows={({ from, to, count }) => (
87+
<DisplayedRowsLabel from={from} to={to} count={count} />
88+
)}
7189
backIconButtonProps={TableUtils.getPaginationBackButtonProps()}
7290
nextIconButtonProps={TableUtils.getPaginationNextButtonProps()}
7391
stickyHeader

0 commit comments

Comments
 (0)