From 6624459a3d012a0cefc9ca917617789354ef86e2 Mon Sep 17 00:00:00 2001 From: Keanu Lee Date: Wed, 15 Mar 2017 15:01:42 -0700 Subject: [PATCH] Remove last offscreen focused item --- iron-list.html | 1 + test/focus.html | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/iron-list.html b/iron-list.html index fa0313c0..c50ca184 100644 --- a/iron-list.html +++ b/iron-list.html @@ -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; diff --git a/test/focus.html b/test/focus.html index 93abff91..fdb2cb8d 100644 --- a/test/focus.html +++ b/test/focus.html @@ -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(); }); });