interesting bug with ComboBox
...
if the items observable list is updated via ObservableList/setAll
(ie, combox.getItems().setAll(...)
) (this appears to be what cljfx does), then the current selected item is lost by the component/JavaFx
if ComboBox/setItems
is invoked directly the issue doesn't manifest -- i don't know the cljfx code/model well enough to know if it could special case the list update for combo boxes
my concrete use case: i need the combo box choices to be updated dynamically (eg, to add a new option) but i don't want to lose the current selection
thanks @vlaaad found it - https://github.com/cljfx/cljfx/issues/102 i'll dig in some
@vlaaad here's a PR that i've confirmed fixes the issue: https://github.com/cljfx/cljfx/pull/113 , let me know if you have any notes. thanks!
Many thanks, I'll have a look once I'm back from vacation, currently I don't have access to PC :)
i have a Java repro & "fix" and a small clfjx repro/example i can share if interested
I think there is even an open issue in cljfx repo about setting items in combo-box. It's possible to create a custom prop that will call setItems, and I think it makes sense to use bug-less version of changing items in built-in items prop — PR welcome!