-
Notifications
You must be signed in to change notification settings - Fork 67
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
API for setting dropdown popup overlay width #2331
Labels
Comments
This bug is basically a one line fix, and yet is over 1.5 years old. What's the holdup?? |
Workaround for Kotlin: use karibu-tools |
Solution for ComboBox and MultiSelectComboBox: @Route("")
public class MainView extends VerticalLayout {
public MainView() {
final ComboBox<String> cb = new ComboBox<>("cb");
cb.setItems("1", "2", "3");
setDropdownWidth(cb, "40em");
final MultiSelectComboBox<String> mcb = new MultiSelectComboBox<>("mcb");
mcb.setItems("1", "2", "3");
setDropdownWidth(mcb, "60em");
add(cb, mcb);
}
private static void setDropdownWidth(ComboBox<?> cb, String width) {
cb.getStyle().set("--vaadin-combo-box-overlay-width", width);
}
private static void setDropdownWidth(MultiSelectComboBox<?> cb, String width) {
cb.getStyle().set("--vaadin-multi-select-combo-box-overlay-width", width);
}
} |
10 tasks
Acceptance criteria: set the width of the dropdown to 30em or larger, and observe that the dropdown is visibly wider than the ComboBox itself. |
sissbruecker
added a commit
that referenced
this issue
Jan 15, 2024
…ayWidth() (#5743) * feat: add ComboBox.setDropdownWidth() and MultiSelectComboBox.setDropdownWidth(). Fixes #2331 * refactoring: rename setDropdownWidth() to setOverlayWidth() * refactoring: rename setDropdownWidth() to setOverlayWidth() * align test names --------- Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe your motivation
In certain apps, certain ComboBoxes tend to have items with long texts. If the text won't fit the default dropdown popup width, the text will wrap, which is often not desired.
It would be good to have a means to override the dropdown width and specify an exact number in pixels.
This was filed as vaadin/vaadin-combo-box-flow#387 ; the issue was closed but not implemented since there's no Java API.
Describe the solution you'd like
I want to be able to call
comboBox.setDropdownWidth("30em")
.Additional context
Workaround/how this function should be implemented:
comboBox.getElement().getStyle().set("--vaadin-combo-box-overlay-width", width.trim())
The text was updated successfully, but these errors were encountered: