Files
gerrit/polygerrit-ui/app/elements/shared/gr-select/gr-select.js
Becky Siegel 7416b235e4 Sync patch set dropdowns on navigation
Previously, on a changelist or file view, if you change the patchset
to a lower number and then click the back button, dropdown value did not
change properly. The issue was related to how the selected option was
rendered in a dom-if. This change refactors the gr-select element to fit this
use case.

Bug: Issue 4800
Change-Id: I66ee5b7aba5421a01ca79f9e72a853a73c32e589
2016-11-02 18:11:24 -07:00

49 lines
1.3 KiB
JavaScript

// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function() {
'use strict';
Polymer({
is: 'gr-select',
extends: 'select',
properties: {
bindValue: {
type: String,
notify: true,
observer: '_updateValue',
},
},
listeners: {
change: '_valueChanged',
'dom-change': '_updateValue',
},
_updateValue: function() {
if (this.bindValue) {
this.value = this.bindValue;
}
},
_valueChanged: function() {
this.bindValue = this.value;
},
ready: function() {
// If not set via the property, set bind-value to the element value.
if (!this.bindValue) { this.bindValue = this.value; }
},
});
})();