When two items are given to a player in creative mode using /loot and one is cleared, multiple times in a tick, they are sometimes lost if the inventory is open while they are being given.
[media]Attached is a datapack. If you download and use this datapack in a world, you can reproduce this bug easily. Empty your inventory, go into creative mode, and run the command /function bug:start and as you are receiving items, open your item. Once all the items have been deposited, you will get a message in chat. You will notice that some of the stone is missing from your inventory, either multiple stacks or just small amounts from a stack.
[media]
This has only been replicated in version 1.16.3, but purely because I did not test other versions.
This has been replicated on both multiplayer and singleplayer servers. Vanilla Minecraft was used on both.
It only seems to happen if the player is in creative mode and has their inventory open while the function runs.