Merge "Fix editable-label losing focus"

This commit is contained in:
Wyatt Allen
2018-06-13 01:50:41 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 7 deletions

View File

@@ -92,7 +92,7 @@
_showDropdown() {
if (this.readOnly || this.editing) { return; }
this._open().then(() => {
return this._open().then(() => {
this.$.input.$.input.focus();
if (!this.$.input.value) { return; }
this.$.input.$.input.setSelectionRange(0, this.$.input.value.length);
@@ -118,7 +118,7 @@
let iters = 0;
const step = () => {
this.async(() => {
if (this.style.display !== 'none') {
if (this.$.dropdown.style.display !== 'none') {
fn.call(this);
} else if (iters++ < AWAIT_MAX_ITERS) {
step.call(this);

View File

@@ -77,14 +77,17 @@ limitations under the License.
assert.isFalse(element.$.dropdown.opened);
assert.isTrue(label.classList.contains('editable'));
assert.equal(label.textContent, 'value text');
const focusSpy = sandbox.spy(element.$.input.$.input, 'focus');
const showSpy = sandbox.spy(element, '_showDropdown');
MockInteractions.tap(label);
Polymer.dom.flush();
// The dropdown is open (which covers up the label):
assert.isTrue(element.$.dropdown.opened);
assert.equal(input.value, 'value text');
return showSpy.lastCall.returnValue.then(() => {
// The dropdown is open (which covers up the label):
assert.isTrue(element.$.dropdown.opened);
assert.isTrue(focusSpy.called);
assert.equal(input.value, 'value text');
});
});
test('title with placeholder', done => {