@@ -867,10 +867,18 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
menuHeight -= up.getOffsetHeight() + down.getOffsetHeight() | |||
+ status.getOffsetHeight(); | |||
} else { | |||
final ComputedStyle s = new ComputedStyle( | |||
final ComputedStyle menuStyle = new ComputedStyle( | |||
menu.getElement()); | |||
menuHeight -= s.getIntProperty("marginBottom") | |||
+ s.getIntProperty("marginTop"); | |||
final ComputedStyle popupStyle = new ComputedStyle( | |||
suggestionPopup.getElement()); | |||
menuHeight -= menuStyle.getIntProperty("marginBottom") | |||
+ menuStyle.getIntProperty("marginTop") | |||
+ menuStyle.getIntProperty("paddingBottom") | |||
+ menuStyle.getIntProperty("paddingTop") | |||
+ popupStyle.getIntProperty("marginBottom") | |||
+ popupStyle.getIntProperty("marginTop") | |||
+ popupStyle.getIntProperty("paddingBottom") | |||
+ popupStyle.getIntProperty("paddingTop"); | |||
} | |||
// If the available page height is really tiny then this will be |
@@ -0,0 +1,25 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.IntStream; | |||
import com.vaadin.annotations.Widgetset; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
@Widgetset("com.vaadin.DefaultWidgetSet") | |||
public class ComboBoxHeight extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
ComboBox<String> comboBox = new ComboBox<>(); | |||
comboBox.setPageLength(0); | |||
comboBox.setItems( | |||
IntStream.range(0, 100) | |||
.mapToObj(i -> "Item number " + String.valueOf(i)) | |||
.collect(Collectors.toList())); | |||
addComponent(comboBox); | |||
} | |||
} |
@@ -0,0 +1,4 @@ | |||
$v-selection-overlay-padding-vertical: 10px; | |||
$v-selection-overlay-padding-horizontal: 10px; | |||
@import "../valo/valo"; |
@@ -0,0 +1,13 @@ | |||
@import "variables"; | |||
@import "../tests-valo/valotest"; | |||
.tests-valo-combobox-height { | |||
@include valotest; | |||
.v-filterselect-suggestpopup { | |||
margin-top: 10px !important; | |||
margin-bottom: 10px; | |||
padding-top: 5px; | |||
padding-bottom: 5px; | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import org.junit.Test; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.elements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
public class ComboBoxHeightTest extends SingleBrowserTest { | |||
@Test | |||
public void testPopupHeight() { | |||
openTestURL(); | |||
assertPopupHeight(); | |||
} | |||
@Test | |||
public void testPopupHeightCustomTheme() { | |||
openTestURL("theme=tests-valo-combobox-height"); | |||
assertPopupHeight(); | |||
} | |||
private void assertPopupHeight() { | |||
ComboBoxElement comboBox = $(ComboBoxElement.class).first(); | |||
comboBox.openPopup(); | |||
WebElement suggestionPopup = comboBox.getSuggestionPopup(); | |||
int suggestionPopupBottom = | |||
suggestionPopup.getLocation().getY() + suggestionPopup.getSize() | |||
.getHeight(); | |||
assertGreaterOrEqual( | |||
"Combo box suggestion popup should not exceed the browser's viewport", | |||
driver.manage().window().getSize().getHeight(), | |||
suggestionPopupBottom); | |||
} | |||
} |