Confirmed in 21w39a
I think it is caused by this feature. The best thing would be to not only make it have to do with whether a player is doing it, but also limit it to transparent blocks. It doesn't make sense that we could throw things through solid blocks.
Affects 18w16a as well.
Looking at this, I think the bug I found is a reproduction of this, though as I said, it's not exactly consistent.
Nobody else mentioned this, but this only happens in windowed mode.
I've been having this issue since before the 1.13 snapshots, and I can confirm it happens in all of them, as well as versions before 1.12.2. It seems to be a computer issue because of this, but it only happens in Minecraft, so I have no idea how to fix it.
Confirmed in 1.18