From 41b81987ccc143dcc8c2d091b3cd0f16a7b679ee Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Fri, 27 Sep 2024 16:13:30 +0100 Subject: [PATCH 1/3] Added triggers for the item focus --- js/McqView.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/McqView.js b/js/McqView.js index 8c8cd5f..8d0b496 100644 --- a/js/McqView.js +++ b/js/McqView.js @@ -1,4 +1,5 @@ import QuestionView from 'core/js/views/questionView'; +import Adapt from 'core/js/adapt'; class McqView extends QuestionView { @@ -33,12 +34,18 @@ class McqView extends QuestionView { 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); } 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); } onItemSelect(event) { From 063f52abbb39b12ab462e9cb2ccfa45912f1466b Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Fri, 27 Sep 2024 17:29:08 +0100 Subject: [PATCH 2/3] Moved isHighlighted functionality to the view --- js/McqView.js | 14 ++------------ templates/mcq.jsx | 3 +-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/js/McqView.js b/js/McqView.js index 8d0b496..cf71303 100644 --- a/js/McqView.js +++ b/js/McqView.js @@ -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) { diff --git a/templates/mcq.jsx b/templates/mcq.jsx index 7700cf5..f0babce 100644 --- a/templates/mcq.jsx +++ b/templates/mcq.jsx @@ -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) =>
Date: Fri, 27 Sep 2024 17:57:00 +0100 Subject: [PATCH 3/3] remoi=ved adapt import --- js/McqView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/McqView.js b/js/McqView.js index cf71303..29b4f18 100644 --- a/js/McqView.js +++ b/js/McqView.js @@ -1,5 +1,4 @@ import QuestionView from 'core/js/views/questionView'; -import Adapt from 'core/js/adapt'; class McqView extends QuestionView {