Skip to content

Commit

Permalink
Fixes maxOverlayHieght #630
Browse files Browse the repository at this point in the history
  • Loading branch information
Phan-ThanhDat committed Jan 25, 2020
1 parent cc48e41 commit 2a52bb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/vaadin-combo-box-dropdown-wrapper.html
Expand Up @@ -254,12 +254,10 @@
_maxOverlayHeight(targetRect) {
const margin = 8;
const minHeight = 116; // Height of two items in combo-box
const bottom = Math.min(window.innerHeight, document.body.scrollHeight - document.body.scrollTop);

if (this.$.dropdown.alignedAbove) {
return Math.max(targetRect.top - margin + Math.min(document.body.scrollTop, 0), minHeight) + 'px';
} else {
return Math.max(bottom - targetRect.bottom - margin, minHeight) + 'px';
return Math.max(document.documentElement.clientHeight - targetRect.bottom - margin, minHeight) + 'px';
}
}

Expand Down
20 changes: 20 additions & 0 deletions test/scrolling.html
Expand Up @@ -45,6 +45,26 @@
});
});

describe('the height of scroller', () => {
beforeEach(() => {
const items = [];

for (let i = 0; i < 100; i++) {
items.push(i.toString());
}

combobox.items = items;
});

it('should the height of scroller extends taller than mins-height for many items', () => {
combobox.open();

const scroller = combobox.$.overlay._scroller;
const height = parseFloat(getComputedStyle(scroller).height.split('p')[0]);
expect(height).to.above(116);
});
});

describe('scrolling position', () => {
beforeEach(() => {
const items = [];
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2a52bb8

Please sign in to comment.