Set quaternion from vector3 field.

Hi, I was writing editor extension, and I wanted users to have the ability to change rotation via TransformHandle in the scene and vector3 field in editor window (just like Transform component does it).
I did it with this simple construction:
This bit records changes through editor:

RotationField.TrackPropertyValue(gridRotationSerialized, (a) => GridRotationField.value = a.vector3Value);
RotationField.RegisterValueChangedCallback((v) =>
            {
                so.Update();
                RotationSerialized.quaternionValue = Quaternion.Euler(v.newValue);
                so.ApplyModifiedProperties();
                SceneView.RepaintAll();
            });

And this bit is responsible for the handle

void DuringSceneGUI(SceneView sceneView)
        {
            Vector3 origin = this.origin;
            Quaternion rotation = this.rotation;
            float uniformScale = this.uniformScale;
            Handles.TransformHandle(ref origin, ref rotation, ref uniformScale);
            so.Update();
            RotationSerialized.quaternionValue = rotation;
            OriginSerialized.vector3Value = origin;
            UniformScaleSerialized.floatValue = uniformScale;
            so.ApplyModifiedProperties();
}

But this way gave me strange behaviour:

I know that the problem lies within this line:
RotationField.TrackPropertyValue(RotationSerialized, (a) => RotationField.value = a.vector3Value);
because without it, it all works normally (except for not being able to record rotation applied via transformHandle)

Also, my method works properly for scale and position, the only problem is rotation. Though I don’t think this is the proper way to do it, cause I’m setting variables to the same value two times in a row when they are changed through editor, which is stupid.

When I investigated I found out that if you try to change rotation of a gameobject in debug mode it behaves in the same way:

So, there must a be a clever trick that transform editor uses in order to work properly (in normal mode I mean). In order to find out what that trick was I researched unity cs reference, and I think the magic happens here:

But this stuff with those nasty bits operations goes way over my head, and I can’t make any sense out of it.

Can someone help me decompile it or suggest a way to fix my problem in some other way?

All about Euler angles and rotations, by StarManta:

https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html

Don’t Quaternion fields show up as euler angles in the inspector by default?