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.
Related issues
is duplicated by
Attachments
Comments

I can confirm in 20w46a.
Can confirm in 21w03a.
Can confirm in 1.16.5 and 21w08b.
Video attached. Relates to MC-150589.
Can confirm in 21w11a.
Can confirm in 1.19.2.