Skip to content

Commit ff50887

Browse files
authored
Merge pull request #2 from pepsico-ecommerce/min-height
Bug: text doesn't display on small heights
2 parents 60791d7 + 08426b1 commit ff50887

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pep-p",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "custom element",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ define('pep-p', {
4444

4545
// Restores the original children
4646
restoreChildren() {
47-
this.innerHTML = '';
47+
this.innerHTML = ''; // clear out all the children
48+
// Create clones of the original children and put them back.
4849
this.originalChildNodes.forEach(child => this.appendChild(child.cloneNode(true)));
4950
},
5051

5152
// render by updating the trimmed text to match the current size.
5253
render() {
54+
// Clear the tooltip.
5355
this.removeAttribute('tooltip');
56+
// Find the minimum height needed to display text.
57+
this.innerHTML = 'ÀEIOUhy';
58+
this.minHeight = this.scrollHeight;
5459
// restore the children and then re-trim to the new size.
5560
this.restoreChildren();
5661
this.trimTextContent();
@@ -63,7 +68,7 @@ define('pep-p', {
6368
// Returns true if the content overflows.
6469
get hasOverflow() {
6570
if (this.scrollWidth <= this.clientWidth
66-
&& this.scrollHeight <= this.clientHeight) {
71+
&& this.scrollHeight <= this.minHeight) {
6772
return false;
6873
}
6974

0 commit comments

Comments
 (0)