Skip to content

Commit 376ec5c

Browse files
authored
fix: Safari focus when there are no draggables left
Resolves a11y issue with using a keyboard in Safari.
1 parent f331884 commit 376ec5c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Drag and Drop XBlock changelog
44
Unreleased
55
---------------------------
66

7+
Version 3.2.2 (2023-10-19)
8+
---------------------------
9+
10+
* Fix Safari focus when there are no draggables left.
11+
712
Version 3.2.1 (2023-10-12)
813
---------------------------
914

drag_and_drop_v2/__init__.py

Lines changed: 1 addition & 1 deletion
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__ = "3.2.1"
4+
__version__ = "3.2.2"

drag_and_drop_v2/public/js/drag_and_drop.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,14 @@ function DragAndDropBlock(runtime, element, configuration) {
13101310
};
13111311

13121312
var focusFirstDraggable = function() {
1313-
$root.find('.item-bank .option').first().focus();
1313+
var draggables = $root.find('.item-bank .option[draggable=true]').toArray();
1314+
if (draggables.length){
1315+
draggables[0].focus();
1316+
}
1317+
else {
1318+
// In case there are no draggable options, we default focus to the first zone.
1319+
$root.find('.target .zone').first().focus();
1320+
}
13141321
};
13151322

13161323
var focusItemFeedbackPopup = function() {

0 commit comments

Comments
 (0)