Commit 6adc3876 authored by dpapad's avatar dpapad Committed by Commit Bot

Settings: Prevent focus escaping to <body> in security keys dialog.

When a dialog's child element is focused and then becomes hidden
the browser unfortunately moves the focus to <body> which in turn
prevents any keydown/keypress listeners on <dialog> from firing.

Also preventing an iron-select event from bubbling, since it
ends up triggering unrelated code (although this is not required
for the fix, it is safer).

Bug: None
Change-Id: Ifaad8070d6cab5b4db7167d461c35dfc5168d2d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648729Reviewed-by: default avatarAdam Langley <agl@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667230}
parent e79c0a15
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
on-close="closeDialog_"> on-close="closeDialog_">
<div slot="title">[[title_]]</div> <div slot="title">[[title_]]</div>
<div slot="body"> <div slot="body">
<iron-pages attr-for-selected="id" selected="[[shown_]]"> <iron-pages attr-for-selected="id" selected="[[shown_]]"
on-iron-select="onIronSelect_">
<div id="initial"> <div id="initial">
<p>$i18n{securityKeysPINTouch}</p> <p>$i18n{securityKeysPINTouch}</p>
<paper-spinner-lite active></paper-spinner-lite> <paper-spinner-lite active></paper-spinner-lite>
......
...@@ -202,9 +202,24 @@ Polymer({ ...@@ -202,9 +202,24 @@ Polymer({
return; return;
} }
this.complete_ = true; this.complete_ = true;
// Setting |complete_| to true hides the |pinSubmitNew| button while it
// has focus, which in turn causes the browser to move focus to the <body>
// element, which in turn prevents subsequent "Enter" keystrokes to be
// handled by cr-dialog itself. Re-focusing manually fixes this.
this.$.dialog.focus();
this.browserProxy_.close(); this.browserProxy_.close();
}, },
/**
* @param {!Event} e
* @private
*/
onIronSelect_: function(e) {
// Prevent this event from bubbling since it is unnecessarily triggering the
// listener within settings-animated-pages.
e.stopPropagation();
},
/** @private */ /** @private */
updatePINButtonValid_: function() { updatePINButtonValid_: function() {
this.setPINButtonValid_ = this.setPINButtonValid_ =
......
...@@ -322,4 +322,8 @@ Polymer({ ...@@ -322,4 +322,8 @@ Polymer({
// the backdrop area. // the backdrop area.
e.preventDefault(); e.preventDefault();
}, },
focus() {
this.$$('.title-container').focus();
},
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment