Ranged to Melee Weapon Switching Still Problematic

I have never had an issue with weapon switching from melee to ranged but the reverse sometimes does not happen. Every now and then, after shooting at the incoming enemy, I try to switch from ranged to melee when the enemy is already in my face, but I find that I am still holding my ranged weapon. I do not always get hit before this happens so this has nothing to do with the bug where one gets hit and then cannot switch.