As a fellow programmer I will now tell the devs how to fix this:

Currently:

Event: - Player clicks tab
Trigger: - Target first target on screen from left to right.

After fix:

Event: - Player clicks tab
Trigger: - Target the target that is nearest the player, as the tooltip says.