Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: third_party/polymer/v1_0/chromium.patch

Issue 2794173002: MD Settings: Fix iron-list losing focus when items change. (Closed)
Patch Set: merge Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/polymer/v1_0/chromium.patch
diff --git a/third_party/polymer/v1_0/chromium.patch b/third_party/polymer/v1_0/chromium.patch
index add37bdc75bed4c7759ca6e09d60f18071f47bc3..f64b85dd037274ac74d8a3774526f92952b24096 100644
--- a/third_party/polymer/v1_0/chromium.patch
+++ b/third_party/polymer/v1_0/chromium.patch
@@ -25,13 +25,76 @@ index 78a2a9ec621c..8b776dd790ea 100644
_ariaDescribedByChanged: function(ariaDescribedBy) {
diff --git a/components-chromium/iron-list/iron-list-extracted.js b/components-chromium/iron-list/iron-list-extracted.js
-index c9e0a9fd5330..5d04e7e9db8c 100644
+index c9e0a9fd5330..bb2f6aad64e8 100644
--- a/components-chromium/iron-list/iron-list-extracted.js
+++ b/components-chromium/iron-list/iron-list-extracted.js
-@@ -1466,6 +1466,10 @@
+@@ -126,6 +126,14 @@
+ scrollOffset: {
+ type: Number,
+ value: 0
++ },
++
++ /**
++ * If set to true, focus on an element will be preserved after rerender.
++ */
++ preserveFocus: {
++ type: Boolean,
++ value: false
+ }
+ },
+
+@@ -895,6 +903,15 @@
+ * to `items`, splices or updates to a single item.
+ */
+ _itemsChanged: function(change) {
++ var rendering = /^items(\.splices){0,1}$/.test(change.path);
++ var lastFocusedIndex, focusedElement;
++ if (rendering && this.preserveFocus) {
++ lastFocusedIndex = this._focusedIndex;
++ focusedElement = this.querySelector('* /deep/ *:focus');
++ }
++
++ var preservingFocus = rendering && this.preserveFocus && focusedElement;
++
+ if (change.path === 'items') {
+ this._virtualStart = 0;
+ this._physicalTop = 0;
+@@ -907,12 +924,11 @@
+ this._physicalItems = this._physicalItems || [];
+ this._physicalSizes = this._physicalSizes || [];
+ this._physicalStart = 0;
+- if (this._scrollTop > this._scrollOffset) {
++ if (this._scrollTop > this._scrollOffset && !preservingFocus) {
+ this._resetScrollPosition(0);
+ }
+ this._removeFocusedItem();
+ this._debounceTemplate(this._render);
+-
+ } else if (change.path === 'items.splices') {
+ this._adjustVirtualIndex(change.value.indexSplices);
+ this._virtualCount = this.items ? this.items.length : 0;
+@@ -921,6 +937,17 @@
+ } else {
+ this._forwardItemPath(change.path.split('.').slice(1).join('.'), change.value);
+ }
++
++ // If the list was in focus when updated, preserve the focus on item.
++ if (preservingFocus) {
++ Polymer.dom.flush();
++ focusedElement.blur(); // paper- elements breaks when focused twice.
++ this._focusPhysicalItem(
++ Math.min(this.items.length - 1, lastFocusedIndex));
++ if (!this._isIndexVisible(this._focusedIndex)) {
++ this.scrollToIndex(this._focusedIndex);
++ }
++ }
+ },
+
+ /**
+@@ -1466,6 +1493,10 @@
return this._physicalIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))];
},
-
+
+ focusItem: function(idx) {
+ this._focusPhysicalItem(idx);
+ },
« no previous file with comments | « no previous file | third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698