Commit fb2126b8 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Fix key event handling in dialogs

If a child dialog is focused, do not pass key events to the main
Print Preview page.

Bug: 869317
Change-Id: I0fd24ff715f92d39fc0f1f51a02688d630a8d219
Reviewed-on: https://chromium-review.googlesource.com/1159527
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580534}
parent 0d9edeed
......@@ -20,7 +20,7 @@
<div slot="title">
<div>[[i18n('advancedSettingsDialogTitle', destination.displayName)]]
</div>
<print-preview-search-box id="searchBox" on-keydown="onKeydown_"
<print-preview-search-box id="searchBox"
hidden$="[[!hasMultipleItems_(
destination.capabilities.printer.vendor_capability)]]"
label="$i18n{advancedSettingsSearchBoxPlaceholder}"
......
......@@ -25,6 +25,10 @@ Polymer({
},
},
listeners: {
'keydown': 'onKeydown_',
},
/** @private {!Array<Node>} */
highlights_: [],
......@@ -52,7 +56,9 @@ Polymer({
*/
onKeydown_: function(e) {
e.stopPropagation();
if (e.key == 'Escape' && !this.$.searchBox.getSearchInput().value.trim()) {
const searchInput = this.$.searchBox.getSearchInput();
if (e.key == 'Escape' &&
(e.composedPath()[0] !== searchInput || !searchInput.value.trim())) {
this.$.dialog.cancel();
e.preventDefault();
}
......
......@@ -160,7 +160,7 @@
<option value="">$i18n{addAccountTitle}</option>
</select>
</div>
<print-preview-search-box id="searchBox" on-keydown="onKeydown_"
<print-preview-search-box id="searchBox"
label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}"
autofocus>
</print-preview-search-box>
......
......@@ -75,6 +75,10 @@ Polymer({
'adjustHeight_(invitation_, showCloudPrintPromo)',
],
listeners: {
'keydown': 'onKeydown_',
},
/** @private {!EventTracker} */
tracker_: new EventTracker(),
......@@ -112,7 +116,9 @@ Polymer({
*/
onKeydown_: function(e) {
e.stopPropagation();
if (e.key == 'Escape' && !this.$.searchBox.getSearchInput().value.trim()) {
const searchInput = this.$.searchBox.getSearchInput();
if (e.key == 'Escape' &&
(e.composedPath()[0] !== searchInput || !searchInput.value.trim())) {
this.$.dialog.cancel();
e.preventDefault();
}
......
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