changeset 1384:29a0e209d81f

RT-22937: Selection issue on editors based on ComboBox with dynamic item list
author jgiles
date Fri, 29 Jun 2012 09:43:49 +1200
parents a81a3544722e
children 2d7d2be9cdb7 f90f6b0e27a4
files javafx-ui-controls/src/javafx/scene/control/ComboBox.java
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/ComboBox.java	Fri Jun 29 09:43:28 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/ComboBox.java	Fri Jun 29 09:43:49 2012 +1200
@@ -384,11 +384,16 @@
     // When it changes, set the selectedItem in the value property.
     private ChangeListener<T> selectedItemListener = new ChangeListener<T>() {
         @Override public void changed(ObservableValue<? extends T> ov, T t, T t1) {
-            if (wasSetAllCalled) {
+            if (wasSetAllCalled && t1 == null) {
                 // no-op: fix for RT-22572 where the developer was completely
                 // replacing all items in the ComboBox, and expecting the 
                 // selection (and ComboBox.value) to remain set. If this isn't
                 // here, we would updateValue(null). 
+                // Additional fix for RT-22937: adding the '&& t1 == null'. 
+                // Without this, there would be circumstances where the user 
+                // selecting a new value from the ComboBox would end up in here,
+                // when we really should go into the updateValue(t1) call below.
+                // We should only ever go into this clause if t1 is null.
                 wasSetAllCalled = false;
             } else {
                 updateValue(t1);