Fix event targeting in menu-editor

Migrating to paper-button within gr-button caused the property path of
the on-tap event to change (the target moved from gr-button to
paper-button), and the menu editor was not updated to reflect that.

Bug: Issue 8440
Change-Id: I3c40ff9c2dc338e9e905cb25eecb2853a92e5f66
(cherry picked from commit 8c346da3b3)
This commit is contained in:
Kasper Nilsson
2017-11-14 16:28:43 -08:00
committed by Paladox none
parent 38860c3c07
commit c9095ac513
2 changed files with 11 additions and 10 deletions

View File

@@ -24,7 +24,7 @@
}, },
_handleMoveUpButton(e) { _handleMoveUpButton(e) {
const index = e.target.dataIndex; const index = Polymer.dom(e).localTarget.dataIndex;
if (index === 0) { return; } if (index === 0) { return; }
const row = this.menuItems[index]; const row = this.menuItems[index];
const prev = this.menuItems[index - 1]; const prev = this.menuItems[index - 1];
@@ -32,7 +32,7 @@
}, },
_handleMoveDownButton(e) { _handleMoveDownButton(e) {
const index = e.target.dataIndex; const index = Polymer.dom(e).localTarget.dataIndex;
if (index === this.menuItems.length - 1) { return; } if (index === this.menuItems.length - 1) { return; }
const row = this.menuItems[index]; const row = this.menuItems[index];
const next = this.menuItems[index + 1]; const next = this.menuItems[index + 1];
@@ -40,7 +40,7 @@
}, },
_handleDeleteButton(e) { _handleDeleteButton(e) {
const index = e.target.dataIndex; const index = Polymer.dom(e).localTarget.dataIndex;
this.splice('menuItems', index, 1); this.splice('menuItems', index, 1);
}, },

View File

@@ -47,9 +47,10 @@ limitations under the License.
// Click the up/down button (according to direction) for the index'th row. // Click the up/down button (according to direction) for the index'th row.
// The index of the first row is 0, corresponding to the array. // The index of the first row is 0, corresponding to the array.
function move(element, index, direction) { function move(element, index, direction) {
const selector = const selector = 'tr:nth-child(' + (index + 1) + ') .move' +
'tr:nth-child(' + (index + 1) + ') .move' + direction + 'Button'; direction + 'Button';
const button = element.$$('tbody').querySelector(selector); const button =
element.$$('tbody').querySelector(selector).$$('paper-button');
MockInteractions.tap(button); MockInteractions.tap(button);
} }
@@ -141,15 +142,15 @@ limitations under the License.
['first name', 'second name', 'third name']); ['first name', 'second name', 'third name']);
// Tap the delete button for the middle item. // Tap the delete button for the middle item.
MockInteractions.tap( MockInteractions.tap(element.$$('tbody')
element.$$('tbody').querySelector('tr:nth-child(2) .remove-button')); .querySelector('tr:nth-child(2) .remove-button').$$('paper-button'));
assertMenuNamesEqual(element, ['first name', 'third name']); assertMenuNamesEqual(element, ['first name', 'third name']);
// Delete remaining items. // Delete remaining items.
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
MockInteractions.tap( MockInteractions.tap(element.$$('tbody')
element.$$('tbody').querySelector('tr:first-child .remove-button')); .querySelector('tr:first-child .remove-button').$$('paper-button'));
} }
assertMenuNamesEqual(element, []); assertMenuNamesEqual(element, []);