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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff --git a/components-chromium/font-roboto/roboto.html b/components-chromium/f ont-roboto/roboto.html 1 diff --git a/components-chromium/font-roboto/roboto.html b/components-chromium/f ont-roboto/roboto.html
2 index 7a24999..4eefcba 100644 2 index 7a24999..4eefcba 100644
3 --- a/components-chromium/font-roboto/roboto.html 3 --- a/components-chromium/font-roboto/roboto.html
4 +++ b/components-chromium/font-roboto/roboto.html 4 +++ b/components-chromium/font-roboto/roboto.html
5 @@ -7,5 +7,4 @@ The complete set of contributors may be found at http://polymer. github.io/CONTRI 5 @@ -7,5 +7,4 @@ The complete set of contributors may be found at http://polymer. github.io/CONTRI
6 Code distributed by Google as part of the polymer project is also 6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATE NTS.txt 7 subject to an additional IP rights grant found at http://polymer.github.io/PATE NTS.txt
8 --> 8 -->
9 -<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400 ,300,300italic,400italic,500,500italic,700,700italic"> 9 -<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400 ,300,300italic,400italic,500,500italic,700,700italic">
10 -<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mon o:400,700"> 10 -<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mon o:400,700">
11 +<link rel="stylesheet" href="chrome://resources/css/roboto.css"> 11 +<link rel="stylesheet" href="chrome://resources/css/roboto.css">
12 diff --git a/components-chromium/paper-input/paper-textarea-extracted.js b/compo nents-chromium/paper-input/paper-textarea-extracted.js 12 diff --git a/components-chromium/paper-input/paper-textarea-extracted.js b/compo nents-chromium/paper-input/paper-textarea-extracted.js
13 index 78a2a9ec621c..8b776dd790ea 100644 13 index 78a2a9ec621c..8b776dd790ea 100644
14 --- a/components-chromium/paper-input/paper-textarea-extracted.js 14 --- a/components-chromium/paper-input/paper-textarea-extracted.js
15 +++ b/components-chromium/paper-input/paper-textarea-extracted.js 15 +++ b/components-chromium/paper-input/paper-textarea-extracted.js
16 @@ -43,8 +43,8 @@ Polymer({ 16 @@ -43,8 +43,8 @@ Polymer({
17 } 17 }
18 }, 18 },
19 19
20 - _ariaLabelledByChanged: function(ariaLabelledBy) { 20 - _ariaLabelledByChanged: function(ariaLabelledBy) {
21 - this.$.input.textarea.setAttribute('aria-labelledby', ariaLabelledBy); 21 - this.$.input.textarea.setAttribute('aria-labelledby', ariaLabelledBy);
22 + _ariaLabelledByChanged: function() { 22 + _ariaLabelledByChanged: function() {
23 + this.$.input.textarea.setAttribute('aria-label', this.label); 23 + this.$.input.textarea.setAttribute('aria-label', this.label);
24 }, 24 },
25 25
26 _ariaDescribedByChanged: function(ariaDescribedBy) { 26 _ariaDescribedByChanged: function(ariaDescribedBy) {
27 diff --git a/components-chromium/iron-list/iron-list-extracted.js b/components-c hromium/iron-list/iron-list-extracted.js 27 diff --git a/components-chromium/iron-list/iron-list-extracted.js b/components-c hromium/iron-list/iron-list-extracted.js
28 index c9e0a9fd5330..5d04e7e9db8c 100644 28 index c9e0a9fd5330..bb2f6aad64e8 100644
29 --- a/components-chromium/iron-list/iron-list-extracted.js 29 --- a/components-chromium/iron-list/iron-list-extracted.js
30 +++ b/components-chromium/iron-list/iron-list-extracted.js 30 +++ b/components-chromium/iron-list/iron-list-extracted.js
31 @@ -1466,6 +1466,10 @@ 31 @@ -126,6 +126,14 @@
32 scrollOffset: {
33 type: Number,
34 value: 0
35 + },
36 +
37 + /**
38 + * If set to true, focus on an element will be preserved after rerender.
39 + */
40 + preserveFocus: {
41 + type: Boolean,
42 + value: false
43 }
44 },
45
46 @@ -895,6 +903,15 @@
47 * to `items`, splices or updates to a single item.
48 */
49 _itemsChanged: function(change) {
50 + var rendering = /^items(\.splices){0,1}$/.test(change.path);
51 + var lastFocusedIndex, focusedElement;
52 + if (rendering && this.preserveFocus) {
53 + lastFocusedIndex = this._focusedIndex;
54 + focusedElement = this.querySelector('* /deep/ *:focus');
55 + }
56 +
57 + var preservingFocus = rendering && this.preserveFocus && focusedElement;
58 +
59 if (change.path === 'items') {
60 this._virtualStart = 0;
61 this._physicalTop = 0;
62 @@ -907,12 +924,11 @@
63 this._physicalItems = this._physicalItems || [];
64 this._physicalSizes = this._physicalSizes || [];
65 this._physicalStart = 0;
66 - if (this._scrollTop > this._scrollOffset) {
67 + if (this._scrollTop > this._scrollOffset && !preservingFocus) {
68 this._resetScrollPosition(0);
69 }
70 this._removeFocusedItem();
71 this._debounceTemplate(this._render);
72 -
73 } else if (change.path === 'items.splices') {
74 this._adjustVirtualIndex(change.value.indexSplices);
75 this._virtualCount = this.items ? this.items.length : 0;
76 @@ -921,6 +937,17 @@
77 } else {
78 this._forwardItemPath(change.path.split('.').slice(1).join('.'), change .value);
79 }
80 +
81 + // If the list was in focus when updated, preserve the focus on item.
82 + if (preservingFocus) {
83 + Polymer.dom.flush();
84 + focusedElement.blur(); // paper- elements breaks when focused twice.
85 + this._focusPhysicalItem(
86 + Math.min(this.items.length - 1, lastFocusedIndex));
87 + if (!this._isIndexVisible(this._focusedIndex)) {
88 + this.scrollToIndex(this._focusedIndex);
89 + }
90 + }
91 },
92
93 /**
94 @@ -1466,6 +1493,10 @@
32 return this._physicalIndexForKey[this._collection.getKey(this._getNormali zedItem(idx))]; 95 return this._physicalIndexForKey[this._collection.getKey(this._getNormali zedItem(idx))];
33 }, 96 },
34 97
35 + focusItem: function(idx) { 98 + focusItem: function(idx) {
36 + this._focusPhysicalItem(idx); 99 + this._focusPhysicalItem(idx);
37 + }, 100 + },
38 + 101 +
39 _focusPhysicalItem: function(idx) { 102 _focusPhysicalItem: function(idx) {
40 if (idx < 0 || idx >= this._virtualCount) { 103 if (idx < 0 || idx >= this._virtualCount) {
41 return; 104 return;
OLDNEW
« 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