I believe I have found some more information on how to recreate this issue, I couldn't see anyone who's included this information yet so: I was testing it with food items on windows. I found it only happening when I stopped eating and in the same moment (or more like a few milliseconds later) switch to a different slot. When i was still holding my right mouse button while switching slot,the issue wouldn't happen. It also seems like it only happens if there is actually an item stack in the slot you are switching to.
I believe I have found some more information on how to recreate this issue, I couldn't see anyone who's included this information yet so:
I was testing it with food items on windows. I found it only happening when I stopped eating and in the same moment (or more like a few milliseconds later) switch to a different slot. When i was still holding my right mouse button while switching slot,the issue wouldn't happen. It also seems like it only happens if there is actually an item stack in the slot you are switching to.