Skip to content

Commit 07af6c5

Browse files
committed
feat: Add 'skip to selected tab' link to fbt view
1 parent 4895e9f commit 07af6c5

File tree

15 files changed

+82
-21
lines changed

15 files changed

+82
-21
lines changed

public/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@
655655
"noAccessEndedCourse": "The feedback period has ended, and feedback can no longer be given for this course. Please check the information above to ensure that the course is correct.",
656656
"notFound": "Cannot find this course feedback! If you entered the URL manually, make sure it is correct",
657657
"interimFeedbackTab": "Interim feedbacks",
658-
"respondents": "Respondents"
658+
"respondents": "Respondents",
659+
"skipToSelectedTab": "Skip to selected tab:"
659660
},
660661
"noadUser": {
661662
"noUser": "Something went wrong, you are currently not logged in. Try going through the email link again or contact the course teacher",

public/locales/fi/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@
649649
"noAccessEndedCourse": "Palauteaika on päättynyt, eikä kurssille voi enää antaa palautetta. Tarkista ylläolevista tiedoista, että kurssi on oikea.",
650650
"notFound": "Tätä kurssipalautetta ei löydy! Jos kirjoitit osoitteen manuaalisesti, tarkista että se on oikein.",
651651
"interimFeedbackTab": "Välipalautteet",
652-
"respondents": "Vastanneet"
652+
"respondents": "Vastanneet",
653+
"skipToSelectedTab": "Siirry valitulle välilehdelle:"
653654
},
654655
"noadUser": {
655656
"noUser": "Jotain meni pieleen, et ole tällä hetkellä kirjatunut. Kokeile sähköpostin linkkiä uudestaan tai ota yhteys kurssin opettajaan",

public/locales/sv/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@
625625
"surveyTabDisabledTooltip": "Enkäten kan inte längre redigeras efter att feedbacken har öppnats",
626626
"editFeedbackResponseTab": "Redigera återkopplingsfeedback",
627627
"interimFeedbackTab": "Mellanrespons",
628-
"respondents": "Respondenter"
628+
"respondents": "Respondenter",
629+
"skipToSelectedTab": "Gå till vald flik:"
629630
},
630631
"noadUser": {
631632
"noUser": "Något gick fel. Du är inte inloggad just nu. Pröva att trycka på e-postens länk igen eller ta kontakt med kursens lärare",

src/client/pages/FeedbackTarget/FeedbackTargetContent.jsx

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react'
22
/** @jsxImportSource @emotion/react */
33

4-
import { Navigate, Route, Routes, useMatch } from 'react-router-dom'
4+
import { Navigate, Route, Routes, useMatch, useLocation } from 'react-router-dom'
55

6-
import { Alert, Box } from '@mui/material'
6+
import { Alert, Box, Link } from '@mui/material'
77

88
import { useTranslation } from 'react-i18next'
99
import {
@@ -46,6 +46,26 @@ import ProtectedRoute from '../../components/common/ProtectedRoute'
4646
import Title from '../../components/common/Title'
4747
import { FeedbackTargetTabsContainer, FeedbackTargetTab } from './FeedbackTargetTabs'
4848
import FeedbackTargetInformation from './FeedbackTargetInformation'
49+
import { getActiveTabName } from './utils'
50+
51+
const styles = {
52+
skipLink: {
53+
position: 'fixed',
54+
top: 0,
55+
left: 0,
56+
zIndex: 1300,
57+
px: 2,
58+
py: 2,
59+
bgcolor: '#01263a',
60+
color: 'white',
61+
// Hide visually but keep focusable
62+
transform: 'translateY(-100%)',
63+
'&:focus': {
64+
transform: 'translateY(0)',
65+
outline: '2px solid #fff',
66+
},
67+
},
68+
}
4969

5070
const FeedbackTargetContent = () => {
5171
const { t, i18n } = useTranslation()
@@ -61,7 +81,7 @@ const FeedbackTargetContent = () => {
6181
feedbackCanBeGiven,
6282
userCreated,
6383
} = feedbackTarget
64-
84+
const { pathname } = useLocation()
6585
const fbtMatch = useMatch('/targets/:feedbackTargetId/*')
6686
const interimMatch = useMatch('/targets/:feedbackTargetId/interim-feedback/:interimFeedbackId/*')
6787
const pathnameBase = interimMatch?.pathnameBase || fbtMatch?.pathnameBase // This has to be done because of recursivity of interim feedbacks
@@ -115,9 +135,16 @@ const FeedbackTargetContent = () => {
115135
<>
116136
<Title>{`${visibleCourseCode} ${courseName}`}</Title>
117137
{!feedbackCanBeGiven && <Alert severity="error">{t('feedbackTargetView:feedbackDisabled')}</Alert>}
118-
138+
<Link href="#feedback-target-tab-content" sx={styles.skipLink}>
139+
{`${t('feedbackTargetView:skipToSelectedTab')} ${getActiveTabName({
140+
currentPath: pathname,
141+
feedbackGiven,
142+
isOpen,
143+
isStudent,
144+
feedbackResponseEmailSent,
145+
})}`}
146+
</Link>
119147
<FeedbackTargetInformation />
120-
121148
<Box
122149
mb="2rem"
123150
sx={{

src/client/pages/FeedbackTarget/tabs/ContinuousFeedback/ContinuousFeedback.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const ContinuousFeedback = () => {
156156
const [feedbackEnabled, setFeedbackEnabled] = useState(continuousFeedbackEnabled)
157157

158158
return (
159-
<Box>
159+
<Box id="feedback-target-tab-content">
160160
{showSettings && (
161161
<ContinuousFeedbackSettings
162162
feedbackTarget={feedbackTarget}

src/client/pages/FeedbackTarget/tabs/EditFeedbackResponse/EditFeedbackResponse.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const EditFeedbackResponse = () => {
6262
}
6363

6464
return (
65-
<Card>
65+
<Card id="feedback-target-tab-content">
6666
<CardContent>
6767
<Instructions title={t('feedbackResponse:instructionTitle')}>
6868
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>

src/client/pages/FeedbackTarget/tabs/FeedbackView/FeedbackView.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const FeedbackView = () => {
226226
}
227227

228228
return (
229-
<>
229+
<Box id="feedback-target-tab-content">
230230
<PrivacyDialog open={privacyDialogOpen} onClose={handleClosePrivacyDialog} />
231231

232232
{isStudent &&
@@ -266,7 +266,7 @@ const FeedbackView = () => {
266266
/>
267267
</Box>
268268
)}
269-
</>
269+
</Box>
270270
)
271271
}
272272

src/client/pages/FeedbackTarget/tabs/InterimFeedback/InterimFeedback.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const InterimFeedback = () => {
6868
}
6969

7070
return (
71-
<Box mb={6} px={1}>
71+
<Box id="feedback-target-tab-content" mb={6} px={1}>
7272
<Box sx={styles.buttonContainer}>
7373
<NorButton
7474
data-cy="interim-feedbacks-add-new"

src/client/pages/FeedbackTarget/tabs/Links/Links.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Links = () => {
1818
const sortedUsers = users.sort((a, b) => a.lastName?.localeCompare(b.lastName) ?? 0)
1919

2020
return (
21-
<Box>
21+
<Box id="feedback-target-tab-content">
2222
<Typography variant="h6">Students and their respective feedback links</Typography>
2323
{sortedUsers.map(user => (
2424
<Box key={user.studentNumber} style={{ marginTop: 5 }}>

src/client/pages/FeedbackTarget/tabs/Logs/Logs.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const Logs = () => {
106106
}
107107

108108
return (
109-
<Box display="flex" flexDirection="column">
109+
<Box id="feedback-target-tab-content" display="flex" flexDirection="column">
110110
{!feedbackTargetLogs?.length > 0 && <Alert severity="info">No logs yet</Alert>}
111111
{feedbackTargetLogs.map((log, idx) => (
112112
<LogItem key={idx} log={log} parseLogMessage={getLogMessage} />

0 commit comments

Comments
 (0)