The bug
When placing a block in a spot that an entity is just passing through, the block disappears after being placed, but the player's inventory is not updated properly. A desync occurs when the player tries to place a block at a location where an entity is just passing through it.
Original description
On 1.14.4 I've noticed an issue where if a block is placed the exact moment that an npc walks into the area you are trying to place in the item will disappear. The item will not be returned to the player's inventory, it'll just vanish completely.
This has happened around 3 times, all these occurring when I try and place a lectern and a pesky villager walks onto the area I'm trying to place in.
Unfortunately I don't have any logs for extra information but I hope this was helpful in some way.
Related issues
is duplicated by
relates to
Attachments
Comments

Can confirm. Can't believe I can't find an earlier ticket about this.

In 20w28a

Duplicate of MC-95720

This also happened to me in singleplayer 1.17.

To clarify:
The block does not disappear completely, it's just a client side desync

Can confirm in 1.19.4

It is still in your inventory, just click on all of the empty spots till it shows up. This has also happened to me.

This is happening to me. And I lose my precious blocks 😭.