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

Side by Side Diff: chrome/browser/resources/options/deletable_item_list.js

Issue 429073006: Take care not to destroy a multi-selection when a child element of a list item receives focus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var List = cr.ui.List; 6 /** @const */ var List = cr.ui.List;
7 /** @const */ var ListItem = cr.ui.ListItem; 7 /** @const */ var ListItem = cr.ui.ListItem;
8 8
9 /** 9 /**
10 * Creates a deletable list item, which has a button that will trigger a call 10 * Creates a deletable list item, which has a button that will trigger a call
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 this.deletable_ = value; 85 this.deletable_ = value;
86 this.closeButtonElement_.disabled = !value; 86 this.closeButtonElement_.disabled = !value;
87 }, 87 },
88 88
89 /** 89 /**
90 * Called when a focusable child element receives focus. Selects this item 90 * Called when a focusable child element receives focus. Selects this item
91 * in the list selection model. 91 * in the list selection model.
92 * @private 92 * @private
93 */ 93 */
94 handleFocus_: function() { 94 handleFocus_: function() {
95 // This handler is also fired when the child receives focus as a result of
96 // the item getting selected by the customized mouse/keyboard handling in
97 // SelectionController. Take care not to destroy a potential multiple
98 // selection in this case.
99 if (this.selected)
100 return;
101
95 var list = this.parentNode; 102 var list = this.parentNode;
96 var index = list.getIndexOfListItem(this); 103 var index = list.getIndexOfListItem(this);
97 list.selectionModel.selectedIndex = index; 104 list.selectionModel.selectedIndex = index;
98 list.selectionModel.anchorIndex = index; 105 list.selectionModel.anchorIndex = index;
99 }, 106 },
100 107
101 /** 108 /**
102 * Don't let the list have a crack at the event. We don't want clicking the 109 * Don't let the list have a crack at the event. We don't want clicking the
103 * close button to change the selection of the list or to focus on the close 110 * close button to change the selection of the list or to focus on the close
104 * button. 111 * button.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 */ 193 */
187 deleteItemAtIndex: function(index) { 194 deleteItemAtIndex: function(index) {
188 }, 195 },
189 }; 196 };
190 197
191 return { 198 return {
192 DeletableItemList: DeletableItemList, 199 DeletableItemList: DeletableItemList,
193 DeletableItem: DeletableItem, 200 DeletableItem: DeletableItem,
194 }; 201 };
195 }); 202 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698