With enchantment tables, anvils, and crafting tables, if you have left items in the UI and exit the UI, those items will pop back into the player's inventory.
The villager trading UI is inconsistent with those. It retains pre-1.12 behavior and spits the items onto the ground. This seems like an unintended inconsistency.
Before posting this bug report, I first spent some time checking for dupes and didn't find anything related. I also engaged in a discussion about it on reddit (https://redd.it/6o6pw5) to assess whether or not it should be considered a "bug." I have also seen plenty of Mojira entries where people file bug reports on inconsistencies, and many are confirmed. So I think this qualifies.