Skip to content

Commit

Permalink
Merge branch 'MDL-80197' of https://github.com/pedrojordao/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Feb 28, 2024
2 parents ae33ac0 + 9239366 commit a42d133
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ CALENDAR.prototype = {
this.toggle_calendar_image();
}
}, this);

// Get the calendarimage element by its ID and check if any of its parents have the modal-dialog class to
// know if the link is inside a modal, if so, set the aria-hidden and tabindex properties to the indicated values.
var calendarimageelement = document.getElementById(this.calendarimage.get('id'));
if (calendarimageelement.closest('.modal-dialog')) {
this.calendarimage.set('aria-hidden', true);
this.calendarimage.set('tabIndex', '-1');
}
},
focus_event: function(e) {
M.form.dateselector.cancel_any_timeout();
Expand Down Expand Up @@ -363,11 +371,9 @@ CALENDAR.prototype = {
// If the enable checkbox is not checked, disable the calendar image and prevent focus.
if (!this.enablecheckbox.get('checked')) {
this.calendarimage.addClass('disabled');
this.calendarimage.setAttribute('tabindex', -1);
this.release_calendar();
} else {
this.calendarimage.removeClass('disabled');
this.calendarimage.setAttribute('tabindex', 0);
}
}
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ CALENDAR.prototype = {
this.toggle_calendar_image();
}
}, this);

// Get the calendarimage element by its ID and check if any of its parents have the modal-dialog class to
// know if the link is inside a modal, if so, set the aria-hidden and tabindex properties to the indicated values.
var calendarimageelement = document.getElementById(this.calendarimage.get('id'));
if (calendarimageelement.closest('.modal-dialog')) {
this.calendarimage.set('aria-hidden', true);
this.calendarimage.set('tabIndex', '-1');
}
},
focus_event: function(e) {
M.form.dateselector.cancel_any_timeout();
Expand Down Expand Up @@ -363,11 +371,9 @@ CALENDAR.prototype = {
// If the enable checkbox is not checked, disable the calendar image and prevent focus.
if (!this.enablecheckbox.get('checked')) {
this.calendarimage.addClass('disabled');
this.calendarimage.setAttribute('tabindex', -1);
this.release_calendar();
} else {
this.calendarimage.removeClass('disabled');
this.calendarimage.setAttribute('tabindex', 0);
}
}
};
Expand Down
10 changes: 8 additions & 2 deletions lib/form/yui/src/dateselector/js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ CALENDAR.prototype = {
this.toggle_calendar_image();
}
}, this);

// Get the calendarimage element by its ID and check if any of its parents have the modal-dialog class to
// know if the link is inside a modal, if so, set the aria-hidden and tabindex properties to the indicated values.
var calendarimageelement = document.getElementById(this.calendarimage.get('id'));
if (calendarimageelement.closest('.modal-dialog')) {
this.calendarimage.set('aria-hidden', true);
this.calendarimage.set('tabIndex', '-1');
}
},
focus_event: function(e) {
M.form.dateselector.cancel_any_timeout();
Expand Down Expand Up @@ -155,11 +163,9 @@ CALENDAR.prototype = {
// If the enable checkbox is not checked, disable the calendar image and prevent focus.
if (!this.enablecheckbox.get('checked')) {
this.calendarimage.addClass('disabled');
this.calendarimage.setAttribute('tabindex', -1);
this.release_calendar();
} else {
this.calendarimage.removeClass('disabled');
this.calendarimage.setAttribute('tabindex', 0);
}
}
};
Expand Down

0 comments on commit a42d133

Please sign in to comment.