The bug
When you are inside an inventory (chest/horse/crafting table/creative inventory...) only visible slots are updated. This way, when you are inside:
Normal player inventory and Survival inventory tab in creative - everything is fine
Most inventories - armor and offhand slots are not updated
Creative item/search tabs - only hotbar is updated
When you remove an item (/clear, /replaceitem with air) from a non-updating slot you get a ghost item - you can't use it properly and it disappears in survival when you update your inventory.
When you add an item (/replaceitem, pick up from ground) - you get an invisible item. It will reappear when you re-enter the world or (in survival) when you update this slot.
How to reproduce
Setup 2 command blocks with significant delay running in a loop, with commands like the following:
/item entity @p container.10 replace minecraft:brick
the second one with another block parameter;
Open the creative menu and switch away from your survival inventory (note that the bug doesn't occur when the menu is closed);
Wait for the command to switch the item and go back to your survival inventory: the item should be replaced but it is not: this is the issue;
Optional: relog and see the item is replaced after all.
Related issues
is duplicated by
Comments


Thanks

Why is the state of this issue still Unconfirmed?

This still affects 1.12.2. Very annoying for my game.

Still affects 1.13, 1.14, 1.15, 1.16.
The NBT of Inventory is actually updated correctly. For example, if you replace a gold block in your offhand with diamond block and trigger this bug, what is displayed in your inventory is gold block. but if you place it, it turns out to be diamond block. So it seems to be a client-side display bug.
But what is weird is that the item that has triggered this bug can be regained if you place it to another slot or just throw it away and pick it up, which means it is more than just a display bug.

Confirmed in 1.15.2 and 1.16 Release Candidate 1.

Confirmed in 1.16.1.
Also applies when the player is looking at a non-inventory GUI such as a book on a lectern–the player's hotbar and offhand will not update when those GUIs are open, causing ghost items.

Note that the lectern is actually internally/over the network an inventory (while held books are not).

Can confirm on 1.16.4

1.16.4 is not out yet tho
Updated command usage for /item:
/item entity @p container.10 replace minecraft:brick
Confirmed for
15w36c It only works once after opening a world, but it seems to affect also players with a closed inventory, however the
/replaceitem
command states it succeededRelates to:
MC-2912: The items seem to appear after reopening the world