From 7e647205971ab7e5fbd68c8c6509b3906153144f Mon Sep 17 00:00:00 2001 From: Neil Blair Date: Thu, 6 Apr 2023 17:56:24 +0100 Subject: [PATCH 1/4] Ensure translation menu links are not keyboard focusable when menu is closed --- origins_translations/js/origins-translations.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/origins_translations/js/origins-translations.js b/origins_translations/js/origins-translations.js index b2d68eda..60f7740e 100644 --- a/origins_translations/js/origins-translations.js +++ b/origins_translations/js/origins-translations.js @@ -39,18 +39,21 @@ } function enableMenuUi(i, elm) { - // Enable the button for toggling the menu let $button = $('.origins-translation-button', elm); + let $menu = $('.origins-translation-menu', elm); // Aria-expanded attribute on the button is used as - // CSS hook to show/hide the menu. + // CSS hook to show/hide the menu and enable/disable + // keyboard focus on menu links. $button .attr('aria-expanded', false) .removeClass('hidden') .click(function (e) { e.preventDefault(); let expanded = $(this).attr('aria-expanded') === 'true' || false; + let tabindex = expanded ? '-1' : '0'; $(this).attr('aria-expanded', !expanded); + $menu.find('a').attr('tabindex', tabindex); }); // If focus leaves the translation menu, it should close. @@ -58,6 +61,8 @@ if ($(this).is(':focus-within') !== true) { // Close it via the button. $button.attr('aria-expanded', false); + // Ensure menu links cannot receive keyboard focus. + $menu.find('a').attr('tabindex', '-1'); } }); From 72f84a7161f0b2daebb982fc5f2c273dca52a6c0 Mon Sep 17 00:00:00 2001 From: DuttonMa Date: Tue, 18 Apr 2023 12:02:29 +0100 Subject: [PATCH 2/4] Added try/catch to allow for error in core PhpMail --- origins_qa/src/Controller/QaAccountsManager.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/origins_qa/src/Controller/QaAccountsManager.php b/origins_qa/src/Controller/QaAccountsManager.php index cef9cb9d..86cb599f 100644 --- a/origins_qa/src/Controller/QaAccountsManager.php +++ b/origins_qa/src/Controller/QaAccountsManager.php @@ -147,18 +147,27 @@ public function toggleAll($action) { 'roles' => 'qa' ]); + $success = TRUE; foreach ($accounts as $account) { /** @var \Drupal\user\UserInterface $account */ if ($action === 'enable') { if (!$account->isActive()) { - $account->activate(); - $account->save(); + try { + $account->activate(); + $account->save(); + } catch (\Throwable $error) { + \Drupal::logger('origins_qa')->error("Error when enabling QA Accounts - " . $error); + } } } else { if ($account->isActive()) { - $account->block(); - $account->save(); + try { + $account->block(); + $account->save(); + } catch (\Throwable $error) { + \Drupal::logger('origins_qa')->error("Error when disabling QA Accounts - " . $error); + } } } } From 1f3955bcdca8bca2c1212051cd29caa69cec0e12 Mon Sep 17 00:00:00 2001 From: DuttonMa Date: Tue, 18 Apr 2023 12:04:15 +0100 Subject: [PATCH 3/4] coding standards --- origins_qa/src/Controller/QaAccountsManager.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/origins_qa/src/Controller/QaAccountsManager.php b/origins_qa/src/Controller/QaAccountsManager.php index 86cb599f..942a4e0d 100644 --- a/origins_qa/src/Controller/QaAccountsManager.php +++ b/origins_qa/src/Controller/QaAccountsManager.php @@ -155,7 +155,8 @@ public function toggleAll($action) { try { $account->activate(); $account->save(); - } catch (\Throwable $error) { + } catch (\Throwable $error) + { \Drupal::logger('origins_qa')->error("Error when enabling QA Accounts - " . $error); } } @@ -165,7 +166,8 @@ public function toggleAll($action) { try { $account->block(); $account->save(); - } catch (\Throwable $error) { + } catch (\Throwable $error) + { \Drupal::logger('origins_qa')->error("Error when disabling QA Accounts - " . $error); } } From 8a8e0eccb7c9721d789577e9ad800fd0512aa91a Mon Sep 17 00:00:00 2001 From: DuttonMa Date: Tue, 18 Apr 2023 12:06:05 +0100 Subject: [PATCH 4/4] coding standards --- origins_qa/src/Controller/QaAccountsManager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/origins_qa/src/Controller/QaAccountsManager.php b/origins_qa/src/Controller/QaAccountsManager.php index 942a4e0d..158833bc 100644 --- a/origins_qa/src/Controller/QaAccountsManager.php +++ b/origins_qa/src/Controller/QaAccountsManager.php @@ -155,8 +155,8 @@ public function toggleAll($action) { try { $account->activate(); $account->save(); - } catch (\Throwable $error) - { + } + catch (\Throwable $error) { \Drupal::logger('origins_qa')->error("Error when enabling QA Accounts - " . $error); } } @@ -166,8 +166,8 @@ public function toggleAll($action) { try { $account->block(); $account->save(); - } catch (\Throwable $error) - { + } + catch (\Throwable $error) { \Drupal::logger('origins_qa')->error("Error when disabling QA Accounts - " . $error); } }