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

Print Preview: Move non-title elements out of dialog <slot='title'>

Remove some noise for screen readers in dialogs by moving non-title
elements out of the [slot='title']. Anything in this slot is read
out when the dialog loads. Move these elements to the body instead.

This change requires updating some CSS styling, in order to keep the
lists the only piece of the dialog that scrolls and to keep the
appearance of the dialogs the same.

Bug: 987324
Change-Id: I0ae6f7b338b7df988c12289f7eca2e876bd99a92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006216
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732964}
parent 32c7a667
...@@ -5,34 +5,55 @@ ...@@ -5,34 +5,55 @@
max-width: calc(100vw - 2 * var(--print-preview-dialog-margin)); max-width: calc(100vw - 2 * var(--print-preview-dialog-margin));
} }
#dialog::part(wrapper) {
height: calc(100vh - 2 * var(--print-preview-dialog-margin));
}
#dialog::part(body-container) {
flex: 1;
}
print-preview-search-box { print-preview-search-box {
margin-bottom: 8px; margin-bottom: 8px;
margin-top: 24px; margin-top: 16px;
}
cr-dialog [slot=body] {
display: flex;
flex-direction: column;
height: 100%;
} }
[slot='body'].searching { #itemList {
flex: 1;
overflow-x: hidden;
overflow-y: overlay;
}
#itemList.searching {
padding-bottom: 20px; padding-bottom: 20px;
padding-top: 20px; padding-top: 20px;
} }
</style> </style>
<cr-dialog id="dialog" on-close="onCloseOrCancel_"> <cr-dialog id="dialog" on-close="onCloseOrCancel_">
<div slot="title"> <div slot="title">
<div>[[i18n('advancedSettingsDialogTitle', destination.displayName)]] [[i18n('advancedSettingsDialogTitle', destination.displayName)]]
</div> </div>
<div slot="body">
<print-preview-search-box id="searchBox" <print-preview-search-box id="searchBox"
hidden$="[[!hasMultipleItems_( hidden$="[[!hasMultipleItems_(
destination.capabilities.printer.vendor_capability)]]" destination.capabilities.printer.vendor_capability)]]"
label="$i18n{advancedSettingsSearchBoxPlaceholder}" label="$i18n{advancedSettingsSearchBoxPlaceholder}"
search-query="{{searchQuery_}}" autofocus> search-query="{{searchQuery_}}" autofocus>
</print-preview-search-box> </print-preview-search-box>
</div> <div id="itemList" class$="[[isSearching_(searchQuery_)]]">
<div slot="body" class$="[[isSearching_(searchQuery_)]]"> <template is="dom-repeat"
<template is="dom-repeat" items="[[destination.capabilities.printer.vendor_capability]]">
items="[[destination.capabilities.printer.vendor_capability]]"> <print-preview-advanced-settings-item capability="[[item]]"
<print-preview-advanced-settings-item capability="[[item]]" settings="[[settings]]">
settings="[[settings]]"> </print-preview-advanced-settings-item>
</print-preview-advanced-settings-item> </template>
</template> </div>
<div class="no-settings-match-hint" <div class="no-settings-match-hint"
hidden$="[[!shouldShowHint_(hasMatching_)]]"> hidden$="[[!shouldShowHint_(hasMatching_)]]">
$i18n{noAdvancedSettingsMatchSearchHint} $i18n{noAdvancedSettingsMatchSearchHint}
......
...@@ -16,25 +16,26 @@ ...@@ -16,25 +16,26 @@
print-preview-search-box { print-preview-search-box {
margin-bottom: 16px; margin-bottom: 16px;
margin-top: 14px; margin-top: 6px;
} }
.user-info { .user-info {
font-size: calc(13 / 15 * 1em);
line-height: calc(20 / 15 * 1em); line-height: calc(20 / 15 * 1em);
margin-bottom: 14px; margin-bottom: 14px;
margin-top: 8px;
} }
.user-info .account-select-label { .user-info .md-select {
padding-inline-end: 18px; width: auto;
} }
.user-info .account-select { #accountSelectLabel {
width: auto color: var(--cr-primary-text-color);
padding-inline-end: 18px;
} }
cr-dialog [slot=body] { cr-dialog [slot=body] {
display: flex;
flex-direction: column;
height: 100%; height: 100%;
} }
...@@ -113,18 +114,14 @@ ...@@ -113,18 +114,14 @@
} }
</style> </style>
<cr-dialog id="dialog" on-close="onCloseOrCancel_"> <cr-dialog id="dialog" on-close="onCloseOrCancel_">
<div slot="title" id="header"> <div slot="title" id="header">$i18n{destinationSearchTitle}</div>
<div>$i18n{destinationSearchTitle}</div> <div slot="body">
<div class="user-info" hidden$="[[!activeUser]]" hidden> <div class="user-info" hidden$="[[!activeUser]]" hidden>
<label class="account-select-label" id="accountSelectLabel"> <label id="accountSelectLabel">$i18n{accountSelectTitle}</label>
$i18n{accountSelectTitle} <select class="md-select"
</label>
<select class="md-select account-select"
aria-labelledby="accountSelectLabel" on-change="onUserChange_"> aria-labelledby="accountSelectLabel" on-change="onUserChange_">
<template is="dom-repeat" items="[[users]]"> <template is="dom-repeat" items="[[users]]">
<option value="[[item]]"> <option value="[[item]]">[[item]]</option>
[[item]]
</option>
</template> </template>
<option value="">$i18n{addAccountTitle}</option> <option value="">$i18n{addAccountTitle}</option>
</select> </select>
...@@ -133,8 +130,6 @@ ...@@ -133,8 +130,6 @@
label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}" label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}"
autofocus> autofocus>
</print-preview-search-box> </print-preview-search-box>
</div>
<div slot="body">
<print-preview-destination-list id="printList" <print-preview-destination-list id="printList"
destinations="[[destinations_]]" destinations="[[destinations_]]"
loading-destinations="[[loadingDestinations_]]" loading-destinations="[[loadingDestinations_]]"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
} }
#list { #list {
max-height: 100%; min-height: var(--destination-item-height);
} }
.throbber-container { .throbber-container {
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
} }
.no-destinations-message { .no-destinations-message {
color: #999;
padding-bottom: 8px; padding-bottom: 8px;
padding-inline-start: 18px; padding-inline-start: 18px;
padding-top: 8px; padding-top: 8px;
...@@ -52,7 +51,8 @@ ...@@ -52,7 +51,8 @@
<div class="no-destinations-message" hidden$="[[hasDestinations_]]"> <div class="no-destinations-message" hidden$="[[hasDestinations_]]">
$i18n{noDestinationsMessage} $i18n{noDestinationsMessage}
</div> </div>
<iron-list id="list" items="[[matchingDestinations_]]"> <iron-list id="list" items="[[matchingDestinations_]]"
hidden$="[[hideList_]]">
<template> <template>
<print-preview-destination-list-item class="list-item" <print-preview-destination-list-item class="list-item"
search-query="[[searchQuery]]" destination="[[item]]" search-query="[[searchQuery]]" destination="[[item]]"
......
...@@ -54,6 +54,12 @@ Polymer({ ...@@ -54,6 +54,12 @@ Polymer({
type: Boolean, type: Boolean,
value: false, value: false,
}, },
/** @private */
hideList_: {
type: Boolean,
value: false,
},
}, },
observers: [ observers: [
...@@ -100,14 +106,19 @@ Polymer({ ...@@ -100,14 +106,19 @@ Polymer({
const maxDisplayedItems = this.offsetHeight / DESTINATION_ITEM_HEIGHT; const maxDisplayedItems = this.offsetHeight / DESTINATION_ITEM_HEIGHT;
const isListFullHeight = maxDisplayedItems <= count; const isListFullHeight = maxDisplayedItems <= count;
const listHeight =
isListFullHeight ? this.offsetHeight : count * DESTINATION_ITEM_HEIGHT;
// Update the throbber and "No destinations" message. // Update the throbber and "No destinations" message.
this.hasDestinations_ = count > 0 || this.loadingDestinations; this.hasDestinations_ = count > 0 || this.loadingDestinations;
this.throbberHidden_ = this.throbberHidden_ =
!this.loadingDestinations || isListFullHeight || !this.hasDestinations_; !this.loadingDestinations || isListFullHeight || !this.hasDestinations_;
this.hideList_ = count === 0;
if (this.hideList_) {
return;
}
const listHeight =
isListFullHeight ? this.offsetHeight : count * DESTINATION_ITEM_HEIGHT;
this.$.list.style.height = listHeight > DESTINATION_ITEM_HEIGHT ? this.$.list.style.height = listHeight > DESTINATION_ITEM_HEIGHT ?
`${listHeight}px` : `${listHeight}px` :
`${DESTINATION_ITEM_HEIGHT}px`; `${DESTINATION_ITEM_HEIGHT}px`;
......
<style include="print-preview-shared cr-input-style"> <style include="print-preview-shared cr-input-style">
:host { :host {
display: flex; display: flex;
font-size: calc(13/15 * 1em);
--cr-input-error-display: none; --cr-input-error-display: none;
} }
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
} }
#dialog div[slot='title'] { #dialog div[slot='title'] {
padding-bottom: 0; padding-bottom: 8px;
} }
#dialog div[slot='button-container'] { #dialog div[slot='button-container'] {
......
...@@ -62,15 +62,18 @@ suite(destination_list_test.suiteName, function() { ...@@ -62,15 +62,18 @@ suite(destination_list_test.suiteName, function() {
const items = const items =
list.shadowRoot.querySelectorAll('print-preview-destination-list-item'); list.shadowRoot.querySelectorAll('print-preview-destination-list-item');
const noMatchHint = list.$$('.no-destinations-message'); const noMatchHint = list.$$('.no-destinations-message');
const ironList = list.$.list;
// Query is initialized to null. All items are shown and the hint is // Query is initialized to null. All items are shown and the hint is
// hidden. // hidden.
assertFalse(ironList.hidden);
items.forEach(item => assertFalse(item.hidden)); items.forEach(item => assertFalse(item.hidden));
assertTrue(noMatchHint.hidden); assertTrue(noMatchHint.hidden);
// Searching for "e" should show "One", "Three", and "Five". // Searching for "e" should show "One", "Three", and "Five".
list.searchQuery = /(e)/ig; list.searchQuery = /(e)/ig;
flush(); flush();
assertFalse(ironList.hidden);
assertEquals(undefined, Array.from(items).find(item => { assertEquals(undefined, Array.from(items).find(item => {
return !item.hidden && return !item.hidden &&
(item.destination.displayName == 'Two' || (item.destination.displayName == 'Two' ||
...@@ -81,6 +84,7 @@ suite(destination_list_test.suiteName, function() { ...@@ -81,6 +84,7 @@ suite(destination_list_test.suiteName, function() {
// Searching for "ABC" should show "One" and "Three". // Searching for "ABC" should show "One" and "Three".
list.searchQuery = /(ABC)/ig; list.searchQuery = /(ABC)/ig;
flush(); flush();
assertFalse(ironList.hidden);
assertEquals(undefined, Array.from(items).find(item => { assertEquals(undefined, Array.from(items).find(item => {
return !item.hidden && item.destination.displayName != 'One' && return !item.hidden && item.destination.displayName != 'One' &&
item.destination.displayName != 'Three'; item.destination.displayName != 'Three';
...@@ -90,6 +94,7 @@ suite(destination_list_test.suiteName, function() { ...@@ -90,6 +94,7 @@ suite(destination_list_test.suiteName, function() {
// Searching for "F" should show "Four" and "Five" // Searching for "F" should show "Four" and "Five"
list.searchQuery = /(F)/ig; list.searchQuery = /(F)/ig;
flush(); flush();
assertFalse(ironList.hidden);
assertEquals(undefined, Array.from(items).find(item => { assertEquals(undefined, Array.from(items).find(item => {
return !item.hidden && item.destination.displayName != 'Four' && return !item.hidden && item.destination.displayName != 'Four' &&
item.destination.displayName != 'Five'; item.destination.displayName != 'Five';
...@@ -100,12 +105,13 @@ suite(destination_list_test.suiteName, function() { ...@@ -100,12 +105,13 @@ suite(destination_list_test.suiteName, function() {
// match" hint. // match" hint.
list.searchQuery = /(UVW)/ig; list.searchQuery = /(UVW)/ig;
flush(); flush();
items.forEach(item => assertTrue(item.hidden)); assertTrue(ironList.hidden);
assertFalse(noMatchHint.hidden); assertFalse(noMatchHint.hidden);
// Searching for 123 should show destinations "Three", "Four", and "Five". // Searching for 123 should show destinations "Three", "Four", and "Five".
list.searchQuery = /(123)/ig; list.searchQuery = /(123)/ig;
flush(); flush();
assertFalse(ironList.hidden);
assertEquals(undefined, Array.from(items).find(item => { assertEquals(undefined, Array.from(items).find(item => {
return !item.hidden && return !item.hidden &&
(item.destination.displayName == 'One' || (item.destination.displayName == 'One' ||
...@@ -116,6 +122,7 @@ suite(destination_list_test.suiteName, function() { ...@@ -116,6 +122,7 @@ suite(destination_list_test.suiteName, function() {
// Clearing the query restores the original state. // Clearing the query restores the original state.
list.searchQuery = null; list.searchQuery = null;
flush(); flush();
assertFalse(ironList.hidden);
items.forEach(item => assertFalse(item.hidden)); items.forEach(item => assertFalse(item.hidden));
assertTrue(noMatchHint.hidden); assertTrue(noMatchHint.hidden);
}); });
......
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