Yes. Some time ago, I made it so lords can only change allegiance to the realm TOing their region, when there is a takeover. I think this has been around a couple years now. There's never been anything to handle duchy changes, though there remains a TODO comment about it.
And yes, as Zakky points out, there are 2 weeks before one can change allegiance. And I know it was 2 weeks ago, 5-7 days ago, meaning you had 3 weeks to finish the TO. I hadn't even appointed anyone to the city since it rejoined us from Eppy (though not from lack of trying), meaning it could have been bought by anyone. I had intended to keep delaying until I was a landless duke, but events with Meuse prompted the move.