forked from vaadin/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When ComboBox popup opens to the left accommodate margin/border/padding.
Fixes vaadin#11718
- Loading branch information
Showing
3 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxAtRightEdge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.vaadin.tests.components.combobox; | ||
|
||
import java.util.Arrays; | ||
|
||
import com.vaadin.server.Page; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.tests.components.AbstractTestUI; | ||
import com.vaadin.ui.ComboBox; | ||
|
||
public class ComboBoxAtRightEdge extends AbstractTestUI { | ||
|
||
@Override | ||
protected void setup(VaadinRequest request) { | ||
ComboBox<String> comboBox = new ComboBox<>("Long items"); | ||
comboBox.setPopupWidth(null); | ||
comboBox.setItems(Arrays.asList("First Very long item to add", | ||
"Second very long item to add", "Third very long item to add")); | ||
comboBox.addStyleName("positionRight"); | ||
|
||
addComponent(comboBox); | ||
|
||
Page.getCurrent().getStyles() | ||
.add(".v-slot.v-slot-positionRight {float:right;}"); | ||
Page.getCurrent().getStyles() | ||
.add(".removePadding {padding: 0px !important;}"); | ||
|
||
getLayout().setMargin(false); | ||
getLayout().setSpacing(false); | ||
getLayout().getParent().addStyleName("removePadding"); | ||
getLayout().getParent().removeStyleNames("v-margin-right", | ||
"v-margin-left"); | ||
} | ||
|
||
@Override | ||
protected Integer getTicketNumber() { | ||
return 11718; | ||
} | ||
|
||
@Override | ||
protected String getTestDescription() { | ||
return "ComboBox popup should fit completely in view, margin/border/padding included."; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAtRightEdgeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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.MultiBrowserTest; | ||
|
||
public class ComboBoxAtRightEdgeTest extends MultiBrowserTest { | ||
|
||
@Test | ||
public void ensurePopupInView() { | ||
openTestURL(); | ||
|
||
ComboBoxElement cb = $(ComboBoxElement.class).first(); | ||
cb.openPopup(); | ||
WebElement popup = cb.getSuggestionPopup(); | ||
|
||
int cbRight = cb.getLocation().getX() + cb.getSize().getWidth(); | ||
int popupRight = popup.getLocation().getX() | ||
+ popup.getSize().getWidth(); | ||
assertGreaterOrEqual(String.format( | ||
"Popup should not reach further right than the ComboBox at the " | ||
+ "right edge of the viewport. ComboBox: %s, Popup: %s", | ||
cbRight, popupRight), cbRight, popupRight); | ||
} | ||
} |