Villagers keep holding item if they go out of stock when player is in the trading GUI
Villager held items don't refresh immediately if the trade availability status has changed.
How to reproduce:
for example: wheat to emerald trade
1. Hold wheat in hand
2. Open trading GUI
3. Keep holding wheat in your hand
4. Trade wheat to emerald until out of stock
5. Villager still stuck holding emerald to indicate wheat to emerald trade
They only refresh if you switch to holding another item.
Note that this is not the behaviour seen when they are restocking.