From f8e9796421cb05ebee3a06238b748ad74f75033c Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 5 Mar 2021 13:13:26 -0800 Subject: [PATCH] Upstream cl/326093618: Fix incorrect height on deselection. --- paper-dropdown-menu-light.js | 6 ++++++ test/paper-dropdown-menu-light.html | 12 +++++++++++- test/paper-dropdown-menu.html | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/paper-dropdown-menu-light.js b/paper-dropdown-menu-light.js index 7fc47a9..0576f12 100644 --- a/paper-dropdown-menu-light.js +++ b/paper-dropdown-menu-light.js @@ -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 ' ', which is required + // for the input height to be correct. Uses 'xa0' instead of ' ' to + // avoid innerHTML. + this.$.input.textContent = '\xa0'; + } } }); diff --git a/test/paper-dropdown-menu-light.html b/test/paper-dropdown-menu-light.html index dcd5508..8598474 100644 --- a/test/paper-dropdown-menu-light.html +++ b/test/paper-dropdown-menu-light.html @@ -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() { @@ -236,4 +246,4 @@ - \ No newline at end of file + diff --git a/test/paper-dropdown-menu.html b/test/paper-dropdown-menu.html index 5c164ee..7b36f17 100644 --- a/test/paper-dropdown-menu.html +++ b/test/paper-dropdown-menu.html @@ -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() {