|
1091 | 1091 | } else if (change.path === 'items.splices') {
|
1092 | 1092 | this._adjustVirtualIndex(change.value.indexSplices);
|
1093 | 1093 | this._virtualCount = this.items ? this.items.length : 0;
|
| 1094 | + // Only blur activeElement if it is a descendant of the list (#505, #507). |
| 1095 | + var activeElement = this._getActiveElement(); |
| 1096 | + if (this.contains(activeElement)) activeElement.blur(); |
1094 | 1097 | // Render only if the affected index is rendered.
|
1095 | 1098 | var affectedIndexRendered = change.value.indexSplices.some(function(splice) {
|
1096 | 1099 | return splice.index + splice.addedCount >= this._virtualStart &&
|
|
1170 | 1173 | // remove the current focused item
|
1171 | 1174 | if (this._focusedItem && this.modelForElement(this._focusedItem)[this.as] === item) {
|
1172 | 1175 | this._removeFocusedItem();
|
1173 |
| - document.activeElement && document.activeElement.blur && document.activeElement.blur(); |
1174 | 1176 | }
|
1175 | 1177 | },
|
1176 | 1178 |
|
|
1608 | 1610 | }
|
1609 | 1611 | var modelTabIndex, activeElTabIndex;
|
1610 | 1612 | var target = Polymer.dom(e).path[0];
|
1611 |
| - var itemsHost = this._itemsParent.node.domHost; |
1612 |
| - var activeEl = Polymer.dom(itemsHost ? itemsHost.root : document).activeElement; |
| 1613 | + var activeEl = this._getActiveElement(); |
1613 | 1614 | var physicalItem = this._physicalItems[this._getPhysicalIndex(model[this.indexAs])];
|
1614 | 1615 | // Safari does not focus certain form controls via mouse
|
1615 | 1616 | // https://bugs.webkit.org/show_bug.cgi?id=118043
|
|
1938 | 1939 | this.modelForElement(item)[prop] = value;
|
1939 | 1940 | }
|
1940 | 1941 | }, this);
|
| 1942 | + }, |
| 1943 | + |
| 1944 | + /* Gets the activeElement of the shadow root/host that contains the list. */ |
| 1945 | + _getActiveElement: function() { |
| 1946 | + var itemsHost = this._itemsParent.node.domHost; |
| 1947 | + return Polymer.dom(itemsHost ? itemsHost.root : document).activeElement; |
1941 | 1948 | }
|
1942 | 1949 |
|
1943 | 1950 | });
|
|
0 commit comments