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..49cf3f23b6843bc2418034173cea3c46674745ad 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(); |
| }, |
| @@ -116,11 +118,12 @@ cr.define('options', function() { |
| if (this.disabled) |
| return; |
| - var target = e.target; |
| - if (target.className == 'close-button') { |
| - var listItem = this.getListItemAncestor(target); |
| - if (listItem) |
| - this.deleteItemAtIndex(this.getIndexOfListItem(listItem)); |
| + if (e.target.className == 'close-button') { |
| + // Reverse through the list of selected indexes to maintain the correct |
| + // index values after deletion. |
| + var selected = this.selectionModel.selectedIndexes; |
| + for (var j = selected.length - 1; j >= 0; j--) |
| + this.deleteItemAtIndex(selected[j]); |
|
stuartmorgan
2011/01/06 19:27:33
Won't this do the wrong thing when clicking the cl
James Hawkins
2011/01/06 20:06:43
Yep, this does the wrong thing in this case. Fixe
|
| } |
| }, |