TLDR
When I CTRL click in my inventory with a machine open such that the machine has modules, the modules get downgraded instead of upgraded.Note: I have not tested this with every module type, only quality modules.
Details and example
Tier 2 uncommon (and better) modules have a higher quality bonus than common T3 quality modules (uncommon T2 => 2.6%, rare T2 => 3.2%, common T3 => 2.5%)I have an assembler that has some quality modules in it, and I CTRL+ left mouse button in my inventory, the modules get automatically updated to be the best I have in my inventory. That's an intended feature to make upgrading modules easier.
However, the game prefers modules of a higher tier, even if they are worse than quality modules of a lower tier.
I tested this only with quality modules (on another planet and don't have quality modules of a different type with me), but the game wanted to replace my rare T2 quality modules with my common T3 quality modules, which resulted in a worse overall quality.
As you can see in the images, it also does it based on order - since I had an epic T2 in the first module slot, it put in a T3, and didn't keep the epic.
(I only have 3 T3 modules in my inventory, hence why the last T2 didn't get replaced)
CTRL + LMB again replaced the rare T2 with the epic T2, which is expected.
EDIT:
By chance, I discovered another interesting quirk -
Let say I have a machine that has 5 T2 uncommon modules. In my inventory, I have 3 rare T3 modules, 3 common T3 modules, and 3 rare T2 modules. (all quality modules).
If I CTRL + LMB, the correct modules get put in - the 5 uncommon T2 modules get replaced with 3 rare T3's and 2 rare T2s. However, if I CTRL + LMB again, the rare T2's get replaced with common T3's as described before.