Skip to content

Commit c3593e9

Browse files
richard67obuisard
andauthored
[4.3] Fix submit button focus on frontend MFA captive login page when using Webauthn (#40555)
* Fix submit button focus on MFA captive site login * Revert "[4.3] Fix javascript error on frontend MFA captive login page (#40330)" This reverts commit b5f5db7. * Use optional chaining operator * Revert unneccessary check for the button * PHPCS --------- Co-authored-by: Olivier Buisard <[email protected]>
1 parent c764698 commit c3593e9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

build/media_source/com_users/js/two-factor-focus.es6.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
document.addEventListener('DOMContentLoaded', () => {
1010
const elCodeField = document.getElementById('users-mfa-code');
1111
const elValidateButton = document.getElementById('users-mfa-captive-button-submit');
12-
const elToolbarCustomElement = document.getElementById('toolbar-user-mfa-submit');
12+
const elToolbarButton = document.getElementById('toolbar-user-mfa-submit')?.querySelector('button');
1313

1414
// Focus the code field. If the code field is hidden, focus the submit button (useful e.g. for WebAuthn)
1515
if (
@@ -21,8 +21,8 @@
2121
if (elValidateButton) {
2222
elValidateButton.focus();
2323
}
24-
if (elToolbarCustomElement) {
25-
elToolbarCustomElement.querySelector('button').focus();
24+
if (elToolbarButton) {
25+
elToolbarButton.focus();
2626
}
2727
}
2828

components/com_users/tmpl/captive/default.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
* @var HtmlView $this View object
2121
* @var CaptiveModel $model The model
2222
*/
23-
$model = $this->getModel();
23+
$model = $this->getModel();
2424

25-
if ($this->renderOptions['field_type'] !== 'custom') {
26-
$this->document->getWebAssetManager()
27-
->useScript('com_users.two-factor-focus');
28-
}
25+
$this->document->getWebAssetManager()
26+
->useScript('com_users.two-factor-focus');
2927

3028
?>
3129
<div class="users-mfa-captive card card-body">

0 commit comments

Comments
 (0)