This is a question about the library, Eureka.
I have a PushRow
with a number of options(names). And I also set the first item of those options as the one selected by default upon initialization.
var names = ["Jake", "Cassie", "Rachel", "Marco", "Ax", "Tobias"]
<<< PushRow<WindowStyle>("NamesRow") {
$0.title = "Names"
$0.options = names
$0.value = names.first
}
I run the app and Jake is selected by default as expected. If I tap on the PushRow
and reselect Jake and now it gets deselected. This is expected behavior, I assume. But I want to avoid deselection if I tap on an already selected option row.
The row
property in onChange
callback closure returns nil
if the same option gets selected. I tried to do a nil check and exit early but it doesn't work. It seems onChange
method is fired after all that deselection happens.
.onChange { row in
guard let selectedName = row.value else {
return
}
}
How can I disable deselection?