Skip to content

Commit

Permalink
fix: Safari focus when there are no draggables left
Browse files Browse the repository at this point in the history
Resolves a11y issue with using a keyboard in Safari.
  • Loading branch information
CefBoud authored Oct 19, 2023
1 parent f331884 commit 376ec5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Drag and Drop XBlock changelog
Unreleased
---------------------------

Version 3.2.2 (2023-10-19)
---------------------------

* Fix Safari focus when there are no draggables left.

Version 3.2.1 (2023-10-12)
---------------------------

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__ = "3.2.1"
__version__ = "3.2.2"
9 changes: 8 additions & 1 deletion drag_and_drop_v2/public/js/drag_and_drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,14 @@ function DragAndDropBlock(runtime, element, configuration) {
};

var focusFirstDraggable = function() {
$root.find('.item-bank .option').first().focus();
var draggables = $root.find('.item-bank .option[draggable=true]').toArray();
if (draggables.length){
draggables[0].focus();
}
else {
// In case there are no draggable options, we default focus to the first zone.
$root.find('.target .zone').first().focus();
}
};

var focusItemFeedbackPopup = function() {
Expand Down

0 comments on commit 376ec5c

Please sign in to comment.