File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
main/java/gwt/material/design/addins/client/combobox
test/java/gwt/material/design/addins/client Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ public class MaterialComboBox<T> extends AbstractValueWidget<List<T>> implements
101101 private boolean hideSearch ;
102102 private int limit ;
103103 private boolean closeOnSelect = true ;
104+ private String dropdownParent = "body" ;
104105 private boolean suppressChangeEvent ;
105106
106107 private int selectedIndex ;
@@ -150,6 +151,7 @@ protected void initialize() {
150151 options .placeholder = placeholder ;
151152 options .maximumSelectionLength = limit ;
152153 options .closeOnSelect = closeOnSelect ;
154+ options .dropdownParent = $ (dropdownParent );
153155
154156 if (clearInputHandler == null ) {
155157 clearInputHandler = addSelectionHandler (valueChangeEvent -> $ (getElement ()).find ("input" ).val ("" ));
@@ -227,6 +229,17 @@ public void add(Widget child) {
227229 listbox .add (child );
228230 }
229231
232+ /**
233+ * Sets the parent element of the dropdown
234+ */
235+ public void setDropdownParent (String dropdownParent ) {
236+ this .dropdownParent = dropdownParent ;
237+ }
238+
239+ public String getDropdownParent () {
240+ return dropdownParent ;
241+ }
242+
230243 /**
231244 * Sets multi-value select boxes.
232245 */
Original file line number Diff line number Diff line change 1919 */
2020package gwt .material .design .addins .client .combobox .js ;
2121
22+ import gwt .material .design .jquery .client .api .JQueryElement ;
2223import jsinterop .annotations .JsPackage ;
2324import jsinterop .annotations .JsProperty ;
2425import jsinterop .annotations .JsType ;
@@ -34,6 +35,9 @@ public class JsComboBoxOptions {
3435 @ JsProperty
3536 public String placeholder ;
3637
38+ @ JsProperty
39+ public JQueryElement dropdownParent ;
40+
3741 @ JsProperty
3842 public boolean allowClear ;
3943
Original file line number Diff line number Diff line change @@ -109,6 +109,12 @@ protected <T extends MaterialComboBox<User>> void checkProperties(T comboBox) {
109109 assertEquals (comboBox .getLabel ().getText (), "label" );
110110 comboBox .setPlaceholder ("placeholder" );
111111 assertEquals (comboBox .getPlaceholder (), "placeholder" );
112+
113+ final String BODY_SELECTOR = "body" ;
114+ final String SELF_SELECTOR = "#" + comboBox .getElement ().getId ();
115+ assertEquals (comboBox .getDropdownParent (), BODY_SELECTOR );
116+ comboBox .setDropdownParent (SELF_SELECTOR );
117+ assertEquals (comboBox .getDropdownParent (), SELF_SELECTOR );
112118 }
113119
114120 protected <T extends MaterialComboBox > void checkEvents (T comboBox ) {
You can’t perform that action at this time.
0 commit comments