When an item is dropped and the player switches selected hotbar slots at the same time, a ghost item is created in the inventory while the real item is dropped on the ground. If the ghost item is stackable or in the first available slot (Where an item would go if the ghost item wasn't in the inventory) the inventory will be deleted. These items seem to be useless though, swords don't do more damage or sweep, the "SelectedItem" tag is empty and most other items don't do anything.
The only interestimg thing I could find were ghost foods and potions being infinitly drank/eaten and tools breaking blocks multiple times untile the fist breaking time was reached.
Also the slot switched to willl visually be an empty slot until used or moved in the inventory.
__ I assume this is due to a server-client desync, on the server side the initial item is dropped and the item in the slot switched to is kept, while on the client side it's the opposite.
Does MC-265756 describe your issue? It seems very similar, except for the way to reproduce.