Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #11718 #11721

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion client/src/main/java/com/vaadin/client/ui/VComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,25 @@ private int getDesiredTopPosition() {
}

private int getDesiredLeftPosition() {
double change = 0.0;
getLogger().severe(
"Changing to be reflected getMainWidth " + getMainWidth());
getLogger().severe("Right position: " + WidgetUtil
.getBoundingClientRect(VComboBox.this.getElement())
.getRight());
getLogger().severe("getoffset left: "
+ VComboBox.this.getElement().getOffsetLeft());
double realWidth = WidgetUtil
.getBoundingClientRect(menu.getElement()).getWidth();
getLogger().severe("REAL WIDTH menu to print" + realWidth);
if (popupWidth == -1 && realWidth > getMainWidth()) {

change = realWidth - getMainWidth();
getLogger().severe("Logging difference:" + change);
}
return toInt32(WidgetUtil
.getBoundingClientRect(VComboBox.this.getElement())
.getLeft());
.getLeft() - change);
}

private native int toInt32(double val)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.vaadin.tests.components.combobox;

import com.vaadin.annotations.Widgetset;
import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Notification;

import java.util.Arrays;

@Widgetset("com.vaadin.DefaultWidgetSet")
public class ComboboxPopupPosition extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
ComboBox<String> nameComboBox = new ComboBox<>("Long items");
nameComboBox.setPopupWidth(null);
nameComboBox.setItems(Arrays.asList("First Very long item to add",
"Second very long item to add", "Third very long item to add"));
nameComboBox.addValueChangeListener(event -> {
Notification.show(nameComboBox.getValue());
});
addComponent(nameComboBox);
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");
nameComboBox.addStyleName("positionRight");
}
}