If you right-click on a bed where the pillow-end block is in direct contact with another block on any side, the perspective changes to that of being in bed but the player model's legs are visible making a strange 'walking-on-air' movement and the dimming of the screen fails to complete and sleep is aborted.
Cannot reproduce. Please attach a screenshot. Are you playing on a server or in singleplayer?