Skip to content

Commit

Permalink
fixup! fix: focus submit after no items and improve go-to-beginning h…
Browse files Browse the repository at this point in the history
…iding
  • Loading branch information
DanielVZ96 committed Jun 10, 2024
1 parent 366cb02 commit d50b3b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
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
24 changes: 19 additions & 5 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 @@ -456,7 +456,7 @@ function DragAndDropTemplates(configuration) {
}
var go_to_beginning_button_class = 'go-to-beginning-button';
if (!ctx.show_go_to_beginning_button) {
go_to_beginning_button_class += ' hidden';
go_to_beginning_button_class += ' sr';
}
return(
h("div.problem-action-buttons-wrapper", {attributes: {'role': 'group', 'aria-label': gettext('Actions')}}, [
Expand Down Expand Up @@ -1330,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 @@ -1810,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

0 comments on commit d50b3b9

Please sign in to comment.