Skip to content

Commit

Permalink
Moved isHighlighted functionality to the view
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmyadams committed Sep 27, 2024
1 parent 41b8198 commit 063f52a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
14 changes: 2 additions & 12 deletions js/McqView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,11 @@ class McqView extends QuestionView {
this.onItemSelect(event);
return;
}
const index = parseInt($(event.currentTarget).data('adapt-index'));
const item = this.model.getChildren().findWhere({ _index: index });
item.set('_isHighlighted', true);
setTimeout(() => {
Adapt.trigger('mcq:itemFocus')
}, 1);
event.currentTarget.classList.add('is-highlighted')
}

onItemBlur(event) {
const index = $(event.currentTarget).data('adapt-index');
const item = this.model.getChildren().findWhere({ _index: index });
item.set('_isHighlighted', false);
setTimeout(() => {
Adapt.trigger('mcq:itemFocus')
}, 1);
event.currentTarget.classList.remove('is-highlighted')
}

onItemSelect(event) {
Expand Down
3 changes: 1 addition & 2 deletions templates/mcq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function Mcq(props) {
aria-label={ariaQuestion || null}
>

{props._items.map(({ text, altText, _index, _isActive, _shouldBeSelected, _isHighlighted }, index) =>
{props._items.map(({ text, altText, _index, _isActive, _shouldBeSelected }, index) =>

<div
className={classes([
Expand Down Expand Up @@ -75,7 +75,6 @@ export default function Mcq(props) {
'mcq-item__label',
'u-no-select',
!_isEnabled && 'is-disabled',
_isHighlighted && 'is-highlighted',
(_isCorrectAnswerShown ? _shouldBeSelected : _isActive) && 'is-selected'
])}
aria-hidden={true}
Expand Down

0 comments on commit 063f52a

Please sign in to comment.