Skip to content

Commit

Permalink
Merge pull request #408 from open-craft/dvz/improve-a11y
Browse files Browse the repository at this point in the history
fix: set go to beginning button to hidden
  • Loading branch information
edx-requirements-bot authored Jun 27, 2024
2 parents 9073a98 + ce71812 commit 92c58ec
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Unreleased

* Adjust code styling for newer pylint versions.

Version 4.0.3 (2024-05-23)
---------------------------

* Set go-to-beginning button to hidden for Screen Readers

Version 4.0.2 (2024-04-24)
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion drag_and_drop_v2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Drag and Drop v2 XBlock """
from .drag_and_drop_v2 import DragAndDropBlock

__version__ = "4.0.2"
__version__ = "4.0.3"
1 change: 0 additions & 1 deletion drag_and_drop_v2/public/css/drag_and_drop.css
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@
color: #000000;
}


/* Prevent mobile browsers from emulating hover effects on item tap, which can be confusing. */
@media (hover: none) {
.xblock--drag-and-drop .drag-container .option[draggable='true']:hover {
Expand Down
38 changes: 31 additions & 7 deletions drag_and_drop_v2/public/js/drag_and_drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function DragAndDropTemplates(configuration) {

return (
h('div.feedback', {
attributes: {'role': 'group', 'aria-label': gettext('Feedback')},
attributes: {'role': 'group', 'aria-label': gettext('Feedback'), 'aria-live': 'polite'},
style: { display: feedback_display }
}, [
h('div.feedback-content',[
Expand Down Expand Up @@ -424,7 +424,7 @@ function DragAndDropTemplates(configuration) {
iconClass = 'fa-spin fa-spinner';
}
return (
h('span.problem-action-button-wrapper', {}, [
h('span.problem-action-button-wrapper', {attributes: {"aria-hidden": options.disabled || false}}, [
h(
'button.problem-action-btn.btn-default.btn-small',
{
Expand Down Expand Up @@ -459,7 +459,7 @@ function DragAndDropTemplates(configuration) {
go_to_beginning_button_class += ' sr';
}
return(
h("div.problem-action-buttons-wrapper", {attributes: {'role': 'group', 'aria-label': gettext('Actions')}}, [
h("div.problem-action-buttons-wrapper", {}, [
sidebarButtonTemplate(
go_to_beginning_button_class,
"fa-arrow-up",
Expand Down Expand Up @@ -1052,6 +1052,16 @@ function DragAndDropBlock(runtime, element, configuration) {
$root.find('.keyboard-help-dialog .modal-dismiss-button').focus();
};

var focusSuccessFeedback = function() {
var $feedback = $element.find('.final');
if ($feedback.is(':visible')) {
$feedback.attr('tabindex', '-1');
$feedback.focus();
return true;
};
return false;
}

var showKeyboardHelp = function(evt) {
var focusId = document.activeElement;
evt.preventDefault();
Expand Down Expand Up @@ -1320,6 +1330,17 @@ function DragAndDropBlock(runtime, element, configuration) {
}
};

var focusSubmitButton = function() {
var submitButton = $root.find('.btn-brand.submit').toArray();
if (submitButton.length){
submitButton[0].focus();
}
else {
// In case there are is no submit button, we default focus to the first zone.
$root.find('.target .zone').first().focus();
}
};

var focusItemFeedbackPopup = function() {
var popup = $root.find('.item-feedback-popup');
if (popup.length && popup.is(":visible")) {
Expand Down Expand Up @@ -1800,8 +1821,11 @@ function DragAndDropBlock(runtime, element, configuration) {
// Move focus the the close button of the feedback popup.
focusItemFeedbackPopup();
} else {
// Next tab press should take us to the "Go to Beginning" button.
state.tab_to_go_to_beginning_button = true;
if ($root.find('.item-bank .option[draggable=true]').length) {
focusFirstDraggable();
} else {
focusSubmitButton();
};
}
})
.fail(function (data) {
Expand Down Expand Up @@ -1829,7 +1853,7 @@ function DragAndDropBlock(runtime, element, configuration) {
applyState();

if (manually_closed) {
focusFirstDraggable();
focusSuccessFeedback() || focusFirstDraggable();
}
};

Expand Down Expand Up @@ -1903,7 +1927,7 @@ function DragAndDropBlock(runtime, element, configuration) {
}).always(function() {
state.submit_spinner = false;
applyState();
focusItemFeedbackPopup() || focusFirstDraggable();
focusItemFeedbackPopup() || focusSuccessFeedback() || focusFirstDraggable();
});
};

Expand Down

0 comments on commit 92c58ec

Please sign in to comment.