Skip to content

Commit

Permalink
Merge pull request #209 from localgovdrupal/fix/2.x/replace-deprecate…
Browse files Browse the repository at this point in the history
…d-javascript-apis

fix: replace deprecated javascript apis
  • Loading branch information
finnlewis authored Jan 21, 2025
2 parents 0dde9d0 + 0eacb75 commit c55caf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
// Trigger create/destroy functions at different screen widths
// based on the value of data-accordion-tabs-switch attribute.
if (window.matchMedia) {
mq.addListener(() => {
mq.addEventListener("change", () => {
breakpointCheck();
});
breakpointCheck();
Expand Down
10 changes: 5 additions & 5 deletions modules/localgov_subsites_paragraphs/js/localgov-tabs.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
tab.addEventListener('keydown', e => {
let newActiveControl;

switch (e.which) {
case 37:
switch (e.key) {
case 'ArrowLeft':
// Left arrow. If there's a previous element, switch to it.
if (i - 1 >= 0) {
newActiveControl = tabList
Expand All @@ -94,7 +94,7 @@
newActiveControl[0].focus();
}
break;
case 39:
case 'ArrowRight':
// Right arrow. If there's a next element, switch to it.
if (i + 1 < tabPanelsNumber) {
newActiveControl = tabList
Expand All @@ -107,7 +107,7 @@
newActiveControl[0].focus();
}
break;
case 40:
case 'ArrowDown':
// Arrow down. Move focus into the active panel.
tabPanels[i].focus();
break;
Expand Down Expand Up @@ -177,7 +177,7 @@
// Trigger create/destroy functions at different screen widths
// based on the value of data-accordion-tabs-switch attribute.
if (window.matchMedia) {
mq.addListener(() => {
mq.addEventListener("change", () => {
breakpointCheck();
});
breakpointCheck();
Expand Down
10 changes: 5 additions & 5 deletions modules/localgov_subsites_paragraphs/js/localgov-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,24 @@
tab.addEventListener('keydown', function (e) {
var newActiveControl = void 0;

switch (e.which) {
case 37:
switch (e.key) {
case 'ArrowLeft':
// Left arrow. If there's a previous element, switch to it.
if (i - 1 >= 0) {
newActiveControl = tabList.querySelectorAll('li')[i - 1].querySelectorAll('button');
Drupal.behaviors.localgovTabs.switchTab(newActiveControl[0], tabs);
newActiveControl[0].focus();
}
break;
case 39:
case 'ArrowRight':
// Right arrow. If there's a next element, switch to it.
if (i + 1 < tabPanelsNumber) {
newActiveControl = tabList.querySelectorAll('li')[i + 1].querySelectorAll('button');
Drupal.behaviors.localgovTabs.switchTab(newActiveControl[0], tabs);
newActiveControl[0].focus();
}
break;
case 40:
case 'ArrowDown':
// Arrow down. Move focus into the active panel.
tabPanels[i].focus();
break;
Expand Down Expand Up @@ -179,7 +179,7 @@
// Trigger create/destroy functions at different screen widths
// based on the value of data-accordion-tabs-switch attribute.
if (window.matchMedia) {
mq.addListener(function () {
mq.addEventListener("change", () => {
breakpointCheck();
});
breakpointCheck();
Expand Down

0 comments on commit c55caf1

Please sign in to comment.