selectedIndex doesn't actually change until after onDelegateClicked completes, which results in the previous value being saved rather than the desired one. This correctly handles the change in setting.