Commit 54d6cb59 authored by lgcheng's avatar lgcheng Committed by Commit Bot

Fix button focus issue.

Since ArcTos page can be loaded before it's shown, focus status is not
correctly set in the case. Try to set the focus status of default
button when the page is shown.

Bug: 831104
Test: Manual.
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I5b62ee8a45de1bfa69152f1b7813918185aaa276
Reviewed-on: https://chromium-review.googlesource.com/1011225
Commit-Queue: Long Cheng <lgcheng@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550415}
parent d98b8ea8
...@@ -417,6 +417,22 @@ login.createScreen('ArcTermsOfServiceScreen', 'arc-tos', function() { ...@@ -417,6 +417,22 @@ login.createScreen('ArcTermsOfServiceScreen', 'arc-tos', function() {
.classList.remove(className); .classList.remove(className);
}, },
/**
* Checks if class exsists in the list of classes of root OOBE MD style and
* legacy style root elements.
* @param {string} className class to check.
*
* @private
*/
hasClass_: function(className) {
if (this.useMDOobe) {
return $('arc-tos-md')
.getElement('arc-tos-dialog-md')
.classList.contains(className);
}
return this.classList.contains(className);
},
/** /**
* Handles event when terms view is loaded. * Handles event when terms view is loaded.
*/ */
...@@ -510,6 +526,28 @@ login.createScreen('ArcTermsOfServiceScreen', 'arc-tos', function() { ...@@ -510,6 +526,28 @@ login.createScreen('ArcTermsOfServiceScreen', 'arc-tos', function() {
// height of ToS webview is not correctly caculated. Recaculate the // height of ToS webview is not correctly caculated. Recaculate the
// height here. // height here.
this.updateTermViewHight_(); this.updateTermViewHight_();
this.focusButton_();
},
/**
* Ensures the correct button is focused when the page is shown.
*
* @private
*/
focusButton_() {
var id;
if (this.hasClass_('arc-tos-loaded')) {
id = 'arc-tos-next-button';
} else if (this.hasClass_('error')) {
id = 'arc-tos-retry-button';
}
if (typeof id === 'undefined')
return;
setTimeout(function() {
this.getElement_(id).focus();
}.bind(this), 0);
}, },
/** /**
......
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