RFR: 8087555: [ChoiceBox] uncontained value not shown
arapte at openjdk.java.net
Mon Apr 27 11:21:51 UTC 2020
On Fri, 24 Apr 2020 15:07:59 GMT, Jeanette Winzenburg <fastegal at openjdk.org> wrote:
> Which seems to be hinted at in a code comment in `SingleSelectionModel.select(item)`:
I agree that selectedIndex should be -1 for an uncontained value, so that the below condition always holds true. And
this is already working well with ComboBox.
The fix for [JDK-8241999](https://bugs.openjdk.java.net/browse/JDK-8241999) would solve most of the behavior
differences of contained Vs uncontained item selection. (that I was looking at selectPrevious(), selectNext()).
> true, that's spec'ed in ComboBox only .. so by analogy I considered it being the same here. Hmm .. might need an update
> of the doc?
Thanks for the the pointer, After reading it, I have a doubtful understanding about it as, that,
The spec is only about `ComboBox.valueProperty()` and not about `SelectionModel.selectedIndex` or
`SelectionModel.selectedItem`. so clearSelection() can/should clear the SelectionModel state but should not clear
And ComboBox does not follow this spec,
In below scenario `ComboBox.valueProperty()` is cleared to NULL.
`comboBox.getSelectionModel().clearSelection();` => clears the SelectionModel.selectedIndex to -1,
SelectionModel.selectedItem and ComboBox.getValue() to NULL.
So I think, for ChoieBox, In addition to doc change we would need fix the behavior as well, and maintain same behavior
of `clearSelection()` with contained and uncontained items.
But again this is a different issue and not related to this fix.
So the fix itself looks good to me along with the upcoming fix for
More information about the openjfx-dev