@Lorin here is the workaround. Whenever you are planning to trade with a villager or feed an animal or use a furnace, always put all your valuable stuff into a trunk and only keep out the stuff you need for your task. You pick up your good stuff from the trunk again later. Since I started doing this I haven't lost any good stuff. Thanks to all the people on this thread who clarified all the conditions under which these losses were happening!
@Lorin here is the workaround. Whenever you are planning to trade with a villager or feed an animal or use a furnace, always put all your valuable stuff into a trunk and only keep out the stuff you need for your task. You pick up your good stuff from the trunk again later. Since I started doing this I haven't lost any good stuff. Thanks to all the people on this thread who clarified all the conditions under which these losses were happening!