Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(998)

Side by Side Diff: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js

Issue 2025583002: MD WebUI: Improve tab focus behavior for toolbar search field (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix closure typo Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(tsergeant): Add tests for cr-toolbar-search-field. 5 // TODO(tsergeant): Add tests for cr-toolbar-search-field.
6 Polymer({ 6 Polymer({
7 is: 'cr-toolbar-search-field', 7 is: 'cr-toolbar-search-field',
8 8
9 behaviors: [CrSearchFieldBehavior], 9 behaviors: [CrSearchFieldBehavior],
10 10
11 properties: { 11 properties: {
12 narrow: { 12 narrow: {
13 type: Boolean, 13 type: Boolean,
14 reflectToAttribute: true, 14 reflectToAttribute: true,
15 }, 15 },
16 16
17 // Prompt text to display in the search field. 17 // Prompt text to display in the search field.
18 label: String, 18 label: String,
19 19
20 // Tooltip to display on the clear search button. 20 // Tooltip to display on the clear search button.
21 clearLabel: String, 21 clearLabel: String,
22 }, 22 },
23 23
24 listeners: { 24 listeners: {
25 'tap': 'showSearch_', 25 'tap': 'showSearch_',
26 }, 26 },
27 27
28 /**
29 * @param {boolean} narrow
dpapad 2016/05/31 18:57:58 @return missing
tsergeant 2016/06/01 01:20:49 Done.
30 * @private
31 */
32 computeIconTabIndex_: function(narrow) {
33 return narrow ? 0 : -1;
34 },
35
28 /** @private */ 36 /** @private */
29 onInputBlur_: function() { 37 onInputBlur_: function() {
30 if (!this.hasSearchText) 38 if (!this.hasSearchText)
31 this.showingSearch = false; 39 this.showingSearch = false;
32 }, 40 },
33 41
34 /** 42 /**
43 * Expand the search field when a key is pressed with it focused. This ensures
44 * it can be used correctly by tab-focusing.
dpapad 2016/05/31 18:57:58 I am a bit skeptical about this behavior UX-wise.
tsergeant 2016/06/01 01:20:49 There's a blinking cursor shown in the field when
45 * @private
46 */
47 onSearchTermKeypress_: function() {
48 if (!this.showingSearch)
dpapad 2016/05/31 18:57:58 Why is this check necessary? Could we blindly set
tsergeant 2016/06/01 01:20:49 Good point, done.
49 this.showingSearch = true;
50 },
51
52 /**
35 * @param {Event} e 53 * @param {Event} e
36 * @private 54 * @private
37 */ 55 */
38 showSearch_: function(e) { 56 showSearch_: function(e) {
39 if (e.target != this.$.clearSearch) 57 if (e.target != this.$.clearSearch)
40 this.showingSearch = true; 58 this.showingSearch = true;
41 }, 59 },
42 60
43 /** 61 /**
44 * @param {Event} e 62 * @param {Event} e
45 * @private 63 * @private
46 */ 64 */
47 hideSearch_: function(e) { 65 hideSearch_: function(e) {
48 this.showingSearch = false; 66 this.showingSearch = false;
49 e.stopPropagation(); 67 e.stopPropagation();
50 } 68 }
51 }); 69 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698