Pretty sure it only happens when you close your inventory while your mouse is hovering over a picture of an item; although I could be wrong, I'm probably around 80% sure that's the issue. Sometimes, not always but definitely sometimes, you can fix it by opening your inventory and hovering over the picture then moving your cursor somewhere else on your screen and closing your inventory again.