-
Bug
-
Resolution: Fixed
-
P3
-
8u20, 9, 10
To reproduce, compile and run
- open dropdown with mouse and select an item: this will remove the combo and re-add it to the parent
- click on re-added combo
- expected: dropdown opened
- actual: nothing happens
This seems to happen if the combo is removed while the dropdown is open. Indicators for that assumption:
a) select item by keyboard without opening -> behaves as expected
b) explicitly hide the combo before removal (in the listener) -> behaves as expected
Similar issue asJDK-8095306 which was fixed to handle the initial showing, but not the dynamic case. So the fix for this should be along those line, f.i. in skin's constructor, install a in a listener to the combo's scene property, which keeps combo's showing in sync with popup's showing
registerChangeListener(combo.sceneProperty(), e -> {
if (combo.getScene() == null) {
// arguable:
// on removal, the popup is hidden,
// force combo to hide also
combo.hide();
} else if (combo.isShowing()) {
// ensure popup is showing
show();
}
});
Also, check DatePickerSkin and any other sub of ComboPopupControl if they have similar issues (initial and dynamic).
Code example (from SO https://stackoverflow.com/q/48538763/203657):
public class ComboBoxTest extends Application {
public static void main(String[] args) {
ComboBoxTest.launch(args);
}
@Override
public void start(Stage stage) {
VBox root = new VBox();
final ComboBox<String> choices = new ComboBox<>();
choices.getItems().add("Test1");
choices.getItems().add("Test2");
root.getChildren().add(choices);
choices.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> {
root.getChildren().clear();
root.getChildren().add(choices);
});
Platform.setImplicitExit(true);
stage.setScene(new Scene(root));
stage.show();
}
}
- open dropdown with mouse and select an item: this will remove the combo and re-add it to the parent
- click on re-added combo
- expected: dropdown opened
- actual: nothing happens
This seems to happen if the combo is removed while the dropdown is open. Indicators for that assumption:
a) select item by keyboard without opening -> behaves as expected
b) explicitly hide the combo before removal (in the listener) -> behaves as expected
Similar issue as
registerChangeListener(combo.sceneProperty(), e -> {
if (combo.getScene() == null) {
// arguable:
// on removal, the popup is hidden,
// force combo to hide also
combo.hide();
} else if (combo.isShowing()) {
// ensure popup is showing
show();
}
});
Also, check DatePickerSkin and any other sub of ComboPopupControl if they have similar issues (initial and dynamic).
Code example (from SO https://stackoverflow.com/q/48538763/203657):
public class ComboBoxTest extends Application {
public static void main(String[] args) {
ComboBoxTest.launch(args);
}
@Override
public void start(Stage stage) {
VBox root = new VBox();
final ComboBox<String> choices = new ComboBox<>();
choices.getItems().add("Test1");
choices.getItems().add("Test2");
root.getChildren().add(choices);
choices.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> {
root.getChildren().clear();
root.getChildren().add(choices);
});
Platform.setImplicitExit(true);
stage.setScene(new Scene(root));
stage.show();
}
}
- relates to
-
JDK-8208523 [Mac, Robot] DatePicker calendar popup is not shown on second click using robot
- Open
-
JDK-8094950 [CSS] javafx.scene.CssStyleHelper calculateValue WARNING: Could not resolve (TableView with ComboBox cell)
- Resolved
-
JDK-8095306 [TableView] TableView custom TableCell with ComboBoxes not editable.
- Resolved