This is definitely a bug, since that feature would make useless the option "upgrade" which would only lead to units less powerful and/or more expensive.
To highlight this even further, if you replace other pieces but leave the non selectable slots alone, you can create unit gear combinations that are more powerful than normal. I.e. if a unit has special chest and leg pieces, you can add a helm and change the weapon - it'll keep the hidden selection of chest and leg pieces for a more powerful/cheaper than standard unit.