Chromium Code Reviews| Index: chrome/browser/resources/options/deletable_item_list.js |
| diff --git a/chrome/browser/resources/options/deletable_item_list.js b/chrome/browser/resources/options/deletable_item_list.js |
| index 6781c5086c414906d1971d57291d2f26053b0da0..9eec8e3d7ccf7decc27f29955388d368043873d4 100644 |
| --- a/chrome/browser/resources/options/deletable_item_list.js |
| +++ b/chrome/browser/resources/options/deletable_item_list.js |
| @@ -61,7 +61,9 @@ cr.define('options', function() { |
| this.closeButtonElement_ = this.ownerDocument.createElement('button'); |
| this.closeButtonElement_.className = 'close-button'; |
| this.closeButtonElement_.addEventListener('mousedown', |
| - this.handleMouseDownOnClose_); |
| + this.handleMouseDownUpOnClose_); |
| + this.closeButtonElement_.addEventListener('mouseup', |
| + this.handleMouseDownUpOnClose_); |
| this.appendChild(this.closeButtonElement_); |
| }, |
| @@ -86,11 +88,11 @@ cr.define('options', function() { |
| /** |
| * Don't let the list have a crack at the event. We don't want clicking the |
| - * close button to select the list. |
| - * @param {Event} e The mouse down event object. |
| + * close button to change the selection of the list. |
| + * @param {Event} e The mouse down/up event object. |
| * @private |
| */ |
| - handleMouseDownOnClose_: function(e) { |
| + handleMouseDownUpOnClose_: function(e) { |
| if (!e.target.disabled) |
| e.stopPropagation(); |
| }, |
| @@ -119,8 +121,19 @@ cr.define('options', function() { |
| var target = e.target; |
| if (target.className == 'close-button') { |
| var listItem = this.getListItemAncestor(target); |
| - if (listItem) |
| - this.deleteItemAtIndex(this.getIndexOfListItem(listItem)); |
| + var selected = this.selectionModel.selectedIndexes; |
| + |
| + // Check if the list item that contains the close button being clicked |
| + // is in the list of selected items. Only delete this item in that case. |
|
stuartmorgan
2011/01/06 20:59:34
The comment (and the logic) are backward here. If
James Hawkins
2011/01/06 21:01:54
Done.
James Hawkins
2011/01/06 21:03:40
Actually fixed now.
|
| + var idx = this.getIndexOfListItem(listItem); |
| + if (selected.indexOf(idx)) { |
| + this.deleteItemAtIndex(idx); |
| + } else { |
| + // Reverse through the list of selected indexes to maintain the |
| + // correct index values after deletion. |
| + for (var j = selected.length - 1; j >= 0; j--) |
| + this.deleteItemAtIndex(selected[j]); |
| + } |
| } |
| }, |