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

Unified Diff: chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js

Issue 2627373002: MD Settings: Save and restore scroll position in iron-list (Closed)
Patch Set: Nits Created 3 years, 11 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
Index: chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
index 6e50fb4efadfc3e536178cd325cc9881ddfe2344..267bf918109534dc9b712b300b6bd5fa2b17f51c 100644
--- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
+++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
@@ -30,19 +30,31 @@ settings.BluetoothAddDeviceBehavior = {
value: /** @return {Array} */ function() {
return [];
},
- observer: 'deviceListChanged_',
+ },
+
+ /**
+ * The ordered list of unpaired bluetooth devices.
+ * @type {!Array<!chrome.bluetooth.Device>}
+ */
+ unpairedDeviceList_: {
+ type: Array,
+ value: /** @return {Array} */ function() {
+ return [];
+ },
},
/**
* Reflects the iron-list selecteditem property.
* @type {!chrome.bluetooth.Device}
*/
- selectedItem: {
+ selectedItem_: {
type: Object,
observer: 'selectedItemChanged_',
},
},
+ observers: ['deviceListChanged_(deviceList.*)'],
+
/** @type {boolean} */
itemWasFocused_: false,
@@ -54,8 +66,14 @@ settings.BluetoothAddDeviceBehavior = {
/** @private */
deviceListChanged_: function() {
+ this.saveScroll(this.$.devices);
+ this.unpairedDeviceList_ = this.deviceList.filter(function(device) {
+ return !device.paired;
+ });
this.updateScrollableContents();
- if (this.itemWasFocused_ || !this.getUnpaired_().length)
+ this.restoreScroll(this.$.devices);
+
+ if (this.itemWasFocused_ || !this.unpairedDeviceList_.length)
return;
// If the iron-list is populated with at least one visible item then
// focus it.
@@ -73,26 +91,17 @@ settings.BluetoothAddDeviceBehavior = {
/** @private */
selectedItemChanged_: function() {
- if (this.selectedItem)
- this.fire('device-event', {action: 'connect', device: this.selectedItem});
- },
-
- /**
- * @return {!Array<!chrome.bluetooth.Device>}
- * @private
- */
- getUnpaired_: function() {
- return this.deviceList.filter(function(device) {
- return !device.paired;
- });
+ if (!this.selectedItem_)
+ return;
+ this.fire('device-event', {action: 'connect', device: this.selectedItem_});
},
/**
- * @return {boolean} True if deviceList contains any unpaired devices.
+ * @return {boolean}
* @private
*/
- haveUnpaired_: function(deviceList) {
- return this.getUnpaired_().length > 0;
+ haveUnpaired_: function() {
+ return this.unpairedDeviceList_.length > 0;
},
};

Powered by Google App Engine
This is Rietveld 408576698