This also happens randomly, no ALT+TAB required. When it happened to me, I could also not type in chat or in a book. Have to quit MC and relaunch the game.
This is not a duplicate of MCPE-174524.
Same.
Same. This needs reopened.
The cursor is in the wrong spot and then messes up anything you type. When you press backspace it'll leave the last character you typed in the chat and you can't get rid of it.
I've done some testing.. it is caused when villagers pathfind. Either to a bed, to a job block, or especially, to avoid a zombie.
Reproduce by grouping a bunch of villagers in a square, build a few 1x1 cages around them and place zombies in the cages. The villagers try to get away and the game lags.
Or, make sure there is at least one bed first, then /fill an area that they can access with a job block. Game lags.
Same issue exist in 1.8.
Affects 1.20.31