Skip to content

Commit 92c58ec

Browse files
Merge pull request #408 from open-craft/dvz/improve-a11y
fix: set go to beginning button to hidden
2 parents 9073a98 + ce71812 commit 92c58ec

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

Changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Unreleased
66

77
* Adjust code styling for newer pylint versions.
88

9+
Version 4.0.3 (2024-05-23)
10+
---------------------------
11+
12+
* Set go-to-beginning button to hidden for Screen Readers
13+
914
Version 4.0.2 (2024-04-24)
1015
--------------------------
1116

drag_and_drop_v2/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
""" Drag and Drop v2 XBlock """
22
from .drag_and_drop_v2 import DragAndDropBlock
33

4-
__version__ = "4.0.2"
4+
__version__ = "4.0.3"

drag_and_drop_v2/public/css/drag_and_drop.css

-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@
815815
color: #000000;
816816
}
817817

818-
819818
/* Prevent mobile browsers from emulating hover effects on item tap, which can be confusing. */
820819
@media (hover: none) {
821820
.xblock--drag-and-drop .drag-container .option[draggable='true']:hover {

drag_and_drop_v2/public/js/drag_and_drop.js

+31-7
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function DragAndDropTemplates(configuration) {
318318

319319
return (
320320
h('div.feedback', {
321-
attributes: {'role': 'group', 'aria-label': gettext('Feedback')},
321+
attributes: {'role': 'group', 'aria-label': gettext('Feedback'), 'aria-live': 'polite'},
322322
style: { display: feedback_display }
323323
}, [
324324
h('div.feedback-content',[
@@ -424,7 +424,7 @@ function DragAndDropTemplates(configuration) {
424424
iconClass = 'fa-spin fa-spinner';
425425
}
426426
return (
427-
h('span.problem-action-button-wrapper', {}, [
427+
h('span.problem-action-button-wrapper', {attributes: {"aria-hidden": options.disabled || false}}, [
428428
h(
429429
'button.problem-action-btn.btn-default.btn-small',
430430
{
@@ -459,7 +459,7 @@ function DragAndDropTemplates(configuration) {
459459
go_to_beginning_button_class += ' sr';
460460
}
461461
return(
462-
h("div.problem-action-buttons-wrapper", {attributes: {'role': 'group', 'aria-label': gettext('Actions')}}, [
462+
h("div.problem-action-buttons-wrapper", {}, [
463463
sidebarButtonTemplate(
464464
go_to_beginning_button_class,
465465
"fa-arrow-up",
@@ -1052,6 +1052,16 @@ function DragAndDropBlock(runtime, element, configuration) {
10521052
$root.find('.keyboard-help-dialog .modal-dismiss-button').focus();
10531053
};
10541054

1055+
var focusSuccessFeedback = function() {
1056+
var $feedback = $element.find('.final');
1057+
if ($feedback.is(':visible')) {
1058+
$feedback.attr('tabindex', '-1');
1059+
$feedback.focus();
1060+
return true;
1061+
};
1062+
return false;
1063+
}
1064+
10551065
var showKeyboardHelp = function(evt) {
10561066
var focusId = document.activeElement;
10571067
evt.preventDefault();
@@ -1320,6 +1330,17 @@ function DragAndDropBlock(runtime, element, configuration) {
13201330
}
13211331
};
13221332

1333+
var focusSubmitButton = function() {
1334+
var submitButton = $root.find('.btn-brand.submit').toArray();
1335+
if (submitButton.length){
1336+
submitButton[0].focus();
1337+
}
1338+
else {
1339+
// In case there are is no submit button, we default focus to the first zone.
1340+
$root.find('.target .zone').first().focus();
1341+
}
1342+
};
1343+
13231344
var focusItemFeedbackPopup = function() {
13241345
var popup = $root.find('.item-feedback-popup');
13251346
if (popup.length && popup.is(":visible")) {
@@ -1800,8 +1821,11 @@ function DragAndDropBlock(runtime, element, configuration) {
18001821
// Move focus the the close button of the feedback popup.
18011822
focusItemFeedbackPopup();
18021823
} else {
1803-
// Next tab press should take us to the "Go to Beginning" button.
1804-
state.tab_to_go_to_beginning_button = true;
1824+
if ($root.find('.item-bank .option[draggable=true]').length) {
1825+
focusFirstDraggable();
1826+
} else {
1827+
focusSubmitButton();
1828+
};
18051829
}
18061830
})
18071831
.fail(function (data) {
@@ -1829,7 +1853,7 @@ function DragAndDropBlock(runtime, element, configuration) {
18291853
applyState();
18301854

18311855
if (manually_closed) {
1832-
focusFirstDraggable();
1856+
focusSuccessFeedback() || focusFirstDraggable();
18331857
}
18341858
};
18351859

@@ -1903,7 +1927,7 @@ function DragAndDropBlock(runtime, element, configuration) {
19031927
}).always(function() {
19041928
state.submit_spinner = false;
19051929
applyState();
1906-
focusItemFeedbackPopup() || focusFirstDraggable();
1930+
focusItemFeedbackPopup() || focusSuccessFeedback() || focusFirstDraggable();
19071931
});
19081932
};
19091933

0 commit comments

Comments
 (0)