-
Notifications
You must be signed in to change notification settings - Fork 0
Remove aria attributes in order to read card body content #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,15 @@ export interface AnswersTableProps { | |
onKeyPress?: () => void; | ||
contentRenderer?: JSX.Element; | ||
instructions?: JSX.Element; | ||
previewMode?: boolean; | ||
} | ||
|
||
export const AnswersTable = (props: AnswersTableProps) => { | ||
let idCounter = 0; | ||
|
||
const { | ||
question, hideAnswers, type = defaultAnswerType, answered_count, choicesEnabled, correct_answer_id, | ||
incorrectAnswerId, answer_id, feedback_html, correct_answer_feedback_html, | ||
incorrectAnswerId, answer_id, feedback_html, correct_answer_feedback_html, previewMode, | ||
show_all_feedback = false, tableFeedbackEnabled, hasCorrectAnswer, onChangeAnswer, onKeyPress, answerIdOrder, instructions | ||
} = props; | ||
if (hideAnswers) { return null; } | ||
|
@@ -53,7 +54,7 @@ export const AnswersTable = (props: AnswersTableProps) => { | |
onChangeAnswer: onChangeAnswer, | ||
type, | ||
answered_count, | ||
disabled: !choicesEnabled, | ||
disabled: previewMode || !choicesEnabled, | ||
show_all_feedback, | ||
tableFeedbackEnabled, | ||
onKeyPress | ||
|
@@ -64,10 +65,10 @@ export const AnswersTable = (props: AnswersTableProps) => { | |
const answersHtml = answers.map((answer, i) => { | ||
const additionalProps: { answer: AnswerType, iter: number, key: string } | ||
= { | ||
answer: { | ||
...answer, | ||
question_id: typeof question.id === 'string' ? parseInt(question.id, 10) : question.id | ||
}, | ||
answer: { | ||
...answer, | ||
question_id: typeof question.id === 'string' ? parseInt(question.id, 10) : question.id | ||
}, | ||
iter: i, | ||
key: `${questionAnswerProps.qid}-option-${i}`, | ||
}; | ||
|
@@ -103,7 +104,17 @@ export const AnswersTable = (props: AnswersTableProps) => { | |
}); | ||
|
||
return ( | ||
<div role="radiogroup" aria-label="Answer choices" className="answers-table"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jivey using NVDA I noticed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The label and role here were recently added for accessibility so they probably need to stay here... can you share a screenshot of the NVDA speech that you are seeing? When I test with focus first off, I get this speech which is reading the options:
Additionally, I'm seeing we have a new issue here I didn't see before: those are being read as clickable, can we disable them while in preview mode? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay yes that seems like a problem, at least for our purposes. It's a newer change that I'm not familiar with: #78 My initial thought is that an aria label shouldn't be on that, as it has a role, but I'm not sure. Can you look into that? And if you determine the label needs to be there, we may have to make it conditional for preview cards... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason role is removing Answers from screen reader. I removed the label just to test but Answers still missing as you can see in my previous screenshot. @TylerZeroMaster maybe you can help us to understand this a11y changes. Are we expecting that answers from a card only appears as "Answer choices" in screen readers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jomcarvajal I think the aria-label and role can be removed from the
I may have followed the original issue, which suggested adding the radiogroup role, too closely when I implemented those changes. After further reading:
So if it works better to create an implicit radiogroup by using same-named radio buttons, then I am all for that solution. |
||
<div | ||
{ | ||
...(!previewMode | ||
? { | ||
role: "radiogroup", | ||
'aria-label': "Answer choices" | ||
} | ||
: {}) | ||
} | ||
className="answers-table" | ||
> | ||
{instructions} | ||
{answersHtml} | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +0,0 @@ | ||
import { ExerciseData, ExerciseQueryData, ExerciseQuestionData, StepBase } from '../../src/types'; | ||
import data from '../../exercises.json'; | ||
import styled from 'styled-components'; | ||
import { Exercise } from './Exercise'; | ||
|
||
const ExerciseWrapper = styled.div` | ||
break-inside: avoid; | ||
|
||
.step-card-body { | ||
padding: 24px 48px !important; | ||
} | ||
|
||
.step-card-footer { | ||
display: none; | ||
} | ||
|
||
.exercise-id { | ||
height: auto; | ||
} | ||
|
||
.exercise-step { | ||
min-height: auto; | ||
} | ||
|
||
.question-feedback { | ||
box-shadow: none !important; | ||
} | ||
|
||
.openstax-answer { | ||
break-inside: avoid; | ||
|
||
.answer-letter-wrapper::after { | ||
content: '' !important; | ||
} | ||
} | ||
`; | ||
|
||
const exercises = (data as ExerciseQueryData).exercises as ExerciseData[]; | ||
|
||
const firstQuestionNumByExercise = exercises.reduce((acc, ex) => ({ | ||
...acc, | ||
[ex.uuid]: acc.questionCounter + 1, | ||
questionCounter: acc.questionCounter + ex.questions.length | ||
}), {questionCounter: 0}); | ||
|
||
// placeholder until exercise data contains correct answer IDs | ||
const formatAnswerData = (questions: ExerciseQuestionData[]) => questions.map((q) => ( | ||
{id: q.id, correct_answer_id: (q.answers.find((a) => a.correctness === '1.0')?.id || '')})); | ||
|
||
const questionStateFields = { | ||
available_points: '1.0', | ||
is_completed: true, | ||
answer_id: '1', | ||
free_response: '', | ||
feedback_html: '', | ||
correct_answer_feedback_html: '', | ||
attempts_remaining: 0, | ||
attempt_number: 1, | ||
incorrectAnswerId: 0 | ||
} | ||
|
||
export const Default = () => ( | ||
<> | ||
{data.title && <h2>Exercises for {data.title}</h2>} | ||
{exercises.map(((exercise) => { | ||
|
||
const step: StepBase = { | ||
id: 1, | ||
uid: exercise.uid, | ||
available_points: '1.0', | ||
}; | ||
|
||
const questionStates = formatAnswerData(exercise.questions).reduce((acc, answer) => { | ||
const {id, correct_answer_id} = answer; | ||
return {...acc, [id]: {...questionStateFields, correct_answer_id}}; | ||
}, {}); | ||
|
||
return ( | ||
<ExerciseWrapper key={exercise.uid}> | ||
<Exercise | ||
key={exercise.uid} | ||
canAnswer={true} | ||
needsSaved={true} | ||
hasMultipleAttempts={false} | ||
onAnswerChange={() => undefined} | ||
onAnswerSave={() => undefined} | ||
onNextStep={() => undefined} | ||
apiIsPending={false} | ||
canUpdateCurrentStep={false} | ||
exercise={exercise} | ||
step={step} | ||
questionNumber={firstQuestionNumByExercise[exercise.uuid]} | ||
numberOfQuestions={exercises.length} | ||
questionStates={questionStates} | ||
show_all_feedback={true} /> | ||
</ExerciseWrapper> | ||
) | ||
}))} | ||
</>); | ||
Uh oh!
There was an error while loading. Please reload this page.