Thanks for the extra detail, Piero. I’ve confirmed the cause: Objo’s desktop text controls currently inherit Avalonia’s default behaviour of clearing a selection when the field loses focus. That explains why SelectionLength is already zero when your preferences code tries to save it. Your app-switch observation is consistent with this; I haven’t separately reproduced that Mac path yet.
This is tracked as a bug for TextField, TextArea, and SearchField.
I’ve noted your Edit-menu suggestion too. The menu items currently stay enabled even when their action has nothing to do; making Copy, Undo, and Redo reflect the field’s current state is a separate change.