Skip to content

Commit

Permalink
fix(modal, flyout): ignore observed non inputs for autofocus
Browse files Browse the repository at this point in the history
The observer should only retrigger autofocus if an input has changed, not for any kind of tabbable element.
  • Loading branch information
lubber-de authored Mar 12, 2023
1 parent 4006122 commit 1d7449f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/definitions/modules/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@
$removedInputs = $(collectNodes(mutation.removedNodes)).filter('a[href], [tabindex], :input');
if ($addedInputs.length > 0 || $removedInputs.length > 0) {
shouldRefreshInputs = true;
ignoreAutofocus = false;
if ($addedInputs.filter(':input').length > 0 || $removedInputs.filter(':input').length > 0) {
ignoreAutofocus = false;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@
$removedInputs = $(collectNodes(mutation.removedNodes)).filter('a[href], [tabindex], :input');
if ($addedInputs.length > 0 || $removedInputs.length > 0) {
shouldRefreshInputs = true;
ignoreAutofocus = false;
if ($addedInputs.filter(':input').length > 0 || $removedInputs.filter(':input').length > 0) {
ignoreAutofocus = false;
}
}
}

Expand Down

0 comments on commit 1d7449f

Please sign in to comment.