Skip to content

Commit

Permalink
Update: Added dropdown a11y labeling (refs #147) (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshillen authored Nov 11, 2024
1 parent f83af11 commit e921b28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions templates/matching.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default function Matching(props) {
}, index) => {
const activeOption = _options.find(option => (option._itemIndex === _index) && option._isActive);
const displayItemAsCorrect = (!_isEnabled && _shouldShowMarking && (_isCorrectAnswerShown || activeOption?._shouldBeSelected));
const questionTitleId = `${_id}-matching-item-${_index}__title`;
const questionTextId = `${_id}-matching-item-${_index}__text`;
const hasMultipleCorrectAnswers = _correctAnswers.length > 1;

return (
Expand All @@ -61,14 +63,14 @@ export default function Matching(props) {

{text &&
<div className="matching-item__title">
<div id={`${_id}-matching-item-${_index}__title`} className="matching-item__title_inner" dangerouslySetInnerHTML={{ __html: compile(text) }}>
<div id={questionTitleId} className="matching-item__title_inner" dangerouslySetInnerHTML={{ __html: compile(text) }}>
</div>
</div>
}

<div className="matching-item__select-container js-matching-item-select-container">

<templates.matchingDropDown {...props} _itemIndex={_index} />
<templates.matchingDropDown {...props} _itemIndex={_index} questionTitleId={questionTitleId} questionTextId={questionTextId}/>

<div className="matching-item__select-state">
<div className="matching-item__select-icon matching-item__select-correct-icon" aria-label={_globals._accessibility._ariaLabels.correct}>
Expand Down
6 changes: 4 additions & 2 deletions templates/matchingDropDown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ export default function MatchingDropDown(props) {
onMouseDown={onStartInteraction}
onTouchStart={onStartInteraction}
onClick={onButtonClick}
ref={button}>
ref={button}
aria-labelledby={props.questionTitleId + ' ' + props.questionTextId}
>

<span className="dropdown__inner js-dropdown-inner" dangerouslySetInnerHTML={{ __html: displayActiveOption?.text }}>
<span id={props.questionTextId} className="dropdown__inner js-dropdown-inner" dangerouslySetInnerHTML={{ __html: displayActiveOption?.text }}>
</span>

<span className="dropdown__icon" aria-hidden="true">
Expand Down

0 comments on commit e921b28

Please sign in to comment.