Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #327 from PolymerElements/upstream-326093618
Browse files Browse the repository at this point in the history
Upstream cl/326093618: Fix incorrect height on deselection.
  • Loading branch information
bicknellr authored Mar 5, 2021
2 parents 711ba23 + f8e9796 commit 929c875
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions paper-dropdown-menu-light.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,5 +586,11 @@ Polymer({
this.$.input.textContent = this.value;
}
this._setHasContent(!!this.value);
if (!this.hasContent) {
// If there is no content then reset to '&nbsp', which is required
// for the input height to be correct. Uses 'xa0' instead of '&nbsp' to
// avoid innerHTML.
this.$.input.textContent = '\xa0';
}
}
});
12 changes: 11 additions & 1 deletion test/paper-dropdown-menu-light.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@
content.selected = null;
expect(dropdownMenu.selectedItem).to.be.equal(null);
});

test('maintains its size', function() {
const initialRect = dropdownMenu.getBoundingClientRect();

content.selected = null;

const deselectedRect = dropdownMenu.getBoundingClientRect();
expect(deselectedRect.width).closeTo(initialRect.width, 1);
expect(deselectedRect.height).closeTo(initialRect.height, 1);
});
});

suite('validation', function() {
Expand Down Expand Up @@ -236,4 +246,4 @@
</script>

</body>
</html>
</html>
10 changes: 10 additions & 0 deletions test/paper-dropdown-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@
content.selected = null;
expect(dropdownMenu.selectedItem).to.be.equal(null);
});

test('maintains its size', function() {
const initialRect = dropdownMenu.getBoundingClientRect();

content.selected = null;

const deselectedRect = dropdownMenu.getBoundingClientRect();
expect(deselectedRect.width).closeTo(initialRect.width, 1);
expect(deselectedRect.height).closeTo(initialRect.height, 1);
});
});

suite('validation', function() {
Expand Down

0 comments on commit 929c875

Please sign in to comment.