To be honest, I figured that it /had/ to be a bad ruling and ...
No, it's all due to the stupid vague line between a "temporary stop", a "detention", and an "arrest". Our various branches of government have struggled with it for two centuries now.
Police need people to interact with them so the officers can do the job of investigating crimes. But legally in order to do that they must seize the thing, seize the person, seize the property, whatever. The requirements about due process, seizure of people and property, the law needed to allow for certain types of temporary seizures of people, and the balance is a hard one.
The traffic stop is just that, a stop. A temporary detention that can only last as long as necessary for the administrative task.
In the ruling (and according to most judges already), the officer stopped the individual and performed the task of writing a citation. Anything more than that is no longer a stop, it becomes either a detention or an arrest.
The ruling is clear on what the problem was here. The officer testified that they "had all their documents back and a copy of the written warning. I got all the reasons for the stop out of the way." Then after the stop was complete he did not allow the man to leave, even after the man asked to go, so the officer could call in a drug-sniffing dog. That was a second detention, done without probable cause (since he had already dealt with the reason for the stop), and was therefore unlawful.