Skip to content

Commit

Permalink
Merge pull request #419 from PolymerElements/remove-last-focus-elem
Browse files Browse the repository at this point in the history
Remove last offscreen focused item
  • Loading branch information
Emmanuel Garcia authored Mar 16, 2017
2 parents 93490bc + 6624459 commit 952dce2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions iron-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@
// Hide the physical item that backfills.
this.translate3d(0, HIDDEN_Y, 0, this._focusBackfillItem);
} else {
this._removeFocusedItem();
this._focusBackfillItem = null;
}
this._offscreenFocusedItem = null;
Expand Down
10 changes: 8 additions & 2 deletions test/focus.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,21 @@
list.items = buildDataSet(100);

Polymer.dom.flush();

list.scroll(0, getFirstItemFromList(list).offsetHeight * list._physicalCount);

requestAnimationFrame(function() {
setTimeout(function() {
var lastOffscreenFocusedItem = list._offscreenFocusedItem;
var firstItem = getFirstItemFromList(list);
firstItem.parentNode.focus();
MockInteractions.focus(firstItem.parentNode);

Polymer.dom.flush();

assert.equal(firstItem, getFirstItemFromList(list),
'Should be the same item after focusing it');
assert.isNull(lastOffscreenFocusedItem.parentNode,
'Should remove the last offscreen focused item');
done();
});
});
Expand Down

0 comments on commit 952dce2

Please sign in to comment.